Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sdd.hp.com!usc!orion.oac.uci.edu!ucivax!ucla-cs!twinsun!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: comp.lang.prolog Subject: Re: Fun With Floats in Quintus Message-ID: <1990Aug14.034632.5561@twinsun.com> Date: 14 Aug 90 03:46:32 GMT References: <3829@bingvaxu.cc.binghamton.edu> Sender: usenet@twinsun.com Organization: Twin Sun, Inc Lines: 24 R. Kym Horsell writes: There are some real numbers which can't be represented in floating point. The language (nor implementation) is not at fault. For example, try to write down the representation of 0.1 (decimal) in binary. This cliche doesn't apply to Iverson's problem. Free-format output should print no more digits than are needed to communicate the value. For example, with IEEE double precision floating point, the closest representable number to 8.1 is X = 8.0999999999999996447286321199499070644378662109375. But when I print X in free format, I should see just "8.1", because it's much shorter and communicates X equally well. For more on this subject, see: William D Clinger How to Read Floating Point Numbers Accurately Sigplan notices 25, 6 (June 1990), 92-101. Guy L. Steele Jr. and Jon L White How to Print Floating-Point Numbers Accurately Sigplan notices 25, 6 (June 1990), 112-126. Perhaps Quintus's problem is that they've stolen some low order bits of the fraction for Prolog tag bits, but their I/O routines are the same as C's and are thus programmed as if the low order bits were significant.