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=2.2 required=5.0 tests=BAYES_00,FROM_WORDY, REPLYTO_WITHOUT_TO_CC autolearn=no 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 07:08:01 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!feed1.news.rcn.net!rcn!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada Subject: Re: float problem Date: Sun, 7 Jul 2002 10:08:01 -0400 Message-ID: References: Reply-To: "Frank J. Lhota" X-Trace: UmFuZG9tSVZPL0pYyRCXPto7bxEz9E2aGXm4+U2pEvjzsd0eOOjpYSX+BqM7iW3f X-Complaints-To: abuse@rcn.com NNTP-Posting-Date: 7 Jul 2002 14:07:52 GMT X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MSMail-Priority: Normal Xref: archiver1.google.com comp.lang.ada:26925 Date: 2002-07-07T14:07:52+00:00 List-Id: The problem is that 0.1 cannot be represented exactly as a floating point number. When you add 5 copies of 0.1 to 1.0, the error in the representation of 0.1 is multiplied by 5. The error is small enough to not affect the printed output, where things are rounded to six significant digits, but it does result in a value of f that is slightly more than -0.5. You can confirm this by adding the following statement right before the statement where f gets incremented by 0.1: if f > -0.5 then Put_Line ( "f > -0.5, that's the problem!" ); end if;