Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Fun With Floats in Quintus Message-ID: <3559@goanna.cs.rmit.oz.au> Date: 14 Aug 90 03:01:53 GMT References: <3829@bingvaxu.cc.binghamton.edu> Distribution: comp Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 38 Seemingly, there are comp.lang.prolog articles not making it to Oz. I missed this one: > In article eiverson@nmsu.edu (Eric Iverson) writes: > >How oh how does one represent the numbers 8.1 and 5.4 in Quintus > >Prolog? I have tried everything I can think of without any luck. But this one got through: In article <3829@bingvaxu.cc.binghamton.edu>, vu0310@bingvaxu.cc.binghamton.edu (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. That's perfectly correct. Old versions of Quintus Prolog used a "short" floating-point format, which exacerbates the problem, but the problem does exist in any floating-point system. However, Quintus Prolog comes with a library package library(long) which implements arbitrary precision rational arithmetic, so there IS a way to represent 8.1 and 5.4 exactly: ?- ensure_loaded(library(long)). ?- eval(X is 81/10), eval(Y is 54/10). X = 81/10 Y = 27/5 I have been telling Quintus for years that bignums and rationals should be in all the versions of QP, not just Xerox Quintus Prolog, but Quintus were much more interested in meeting the needs expressed by their paying customers before adding "neat" features that customers weren't asking for. library(long) isn't as nice as having these things built in, but it does the job. I'm still looking after the Quintus Prolog library, and if you have any problems with library(long), please tell me. -- The taxonomy of Pleistocene equids is in a state of confusion.