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=-0.1 required=5.0 tests=AXB_XMAILER_MIMEOLE_OL_024C2, BAYES_00,MAILING_LIST_MULTI,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-08 19:15:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: float problem Date: Mon, 8 Jul 2002 21:14:19 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1026180904 40245 137.194.161.2 (9 Jul 2002 02:15:04 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 9 Jul 2002 02:15:04 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:26957 Date: 2002-07-08T21:14:19-05:00 ----- Original Message ----- From: "Robert A Duff" Newsgroups: comp.lang.ada To: Sent: July 08, 2002 8:05 PM Subject: Re: float problem > "David C. Hoos" writes: > > > It is impossible for _any_ computer language or compiler to _not_ > > round when converting to machine representation to decimal > > representation, unless the machine representation is decimal -- > > something that no modern machine does. This is because only certain > > decimal values are _exactly_ representable in binary. For example > > 0.1 is not exactly representable in binary, but values like 0.125, 0.375, > > etc. are exactly representable. > > I think you have it backwards. > Yes, I realized my misstatement after I had punched the "send" button. What I had in mind was the usual situation where one uses (say) 15 significant digits to represent the value of a 64-bit floating point item. The real point there is that since the binary value is in all liklihood inexact, any digits decimal beyond 15 are uncertain. If, on the other hand, the binary value is presumed exact, then the fractional part of the decimal representation can be exactly done with one decimal digit for every bit in the binary fraction. > Every binary value is representable exactly in decimal, so it *is* > possible to display floating point values (whose radix is 2, as is > usual) in decimal without rounding (or truncation or whatever). You > just need to display enough digits (which will be a finite number). > > Your comments apply to the other way 'round (e.g., 'Value of 0.1 cannot > produce an exact floating-point representation of 0.1 -- assuming the > radix is 2). > > I just got done reading Volume 2 of Knuth, which I've put off for years, > because I'm much more interested in (say) storage allocation than > numerics stuff. Anyway, he discusses this issue in problem 4 of section > 4.4 (a whole section on "Radix Conversion"!). > > - Bob > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada > >