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-08 18:06:35 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newspeer.monmouth.com!priapus.visi.com!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!world!news From: Robert A Duff Subject: Re: float problem Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Tue, 9 Jul 2002 01:05:48 GMT References: NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:26956 Date: 2002-07-09T01:05:48+00:00 List-Id: "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. 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