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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,319c841368a8705a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-07 14:06:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-05!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: achrist@easystreet.com Newsgroups: comp.lang.ada Subject: Re: gnat: float problem Date: Sun, 07 Jul 2002 14:04:49 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <3D28ACF1.4720A915@easystreet.com> X-Mailer: Mozilla 4.79 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:26930 Date: 2002-07-07T14:04:49-07:00 List-Id: Jan Prazak wrote: > > I know that floating point numbers are not very exact, but this really > looks like a bug, because -5.00000E-01 == -0.5. This is all fairly reasonable, given that 0.1 cannot be exactly represented as a floating point on a binary machine. I believe that this will be rounded and may be approximated as slighltly more than 0.1. In hexadecimal, this is 0.199999999... I think, so there is a good chance that rounding will go upward (50% of the less significant bits being ones). Question: 0.5 and -0.5 are decimal numbers that can be represented exactly as floating point. Is the compiler required to figure this out? If it converted 0.5 to binary the dumb way, ie taking 5 times 0.1, it might not get it right. Which compilers always get this kind of conversion correct? Al