From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,acba876b1e3c9639 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!tudelft.nl!txtfeed1.tudelft.nl!news.buerger.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: GNAT Optimization of Constant Expressions Date: Fri, 18 May 2007 21:44:17 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1179355028.624745.258370@q75g2000hsh.googlegroups.com> <464cb4cd$1_3@news.bluewin.ch> <1179528686.946797.189500@w5g2000hsg.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1179542538 20070 69.95.181.76 (19 May 2007 02:42:18 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 19 May 2007 02:42:18 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:15850 Date: 2007-05-18T21:44:17-05:00 List-Id: "Adam Beneschan" wrote in message news:1179528686.946797.189500@w5g2000hsg.googlegroups.com... > On May 18, 10:40 am, "Randy Brukardt" wrote: .... > So I suspect Randy is right, but I'm not sure. If the hardware keeps > just one extra mantissa bit internally when it does the subtraction, > and uses the extra bit when it shifts left to normalize the result, > then I think the two expressions will always produce the same result. No, I think you have it right. The point is that if you subtract 1.0, you depend on the hardware to do the right thing to preserve the last bit (which is shifted out, then back in), whereas if you subtract 0.5 twice, you always get the most accurate possible answer without worrying about what the hardware does. Thus hardcore numerical programs do things like this so that they don't depend on the characteristics of the hardware. Assuming an optimizer doesn't screw that up... Of course, if the hardware takes pains to preserve that extra bit (and a lot of it does), none of this matters that much. Since most optimizers are at least partially machine independent, however, they need to be careful; and in any case, they need to avoid any optmizations which have the potential of losing more bits. Randy.