🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ti.explorer
Article #423

Re: Bug or Feature??

#423
From: James Rice
Date: Wed, 27 Dec 1989 19:26
45 lines
1969 bytes
>>  Hello all of you out there in explorer-land.

>>  I was doing some Q/A on my system and tried this:

>>  (setq number 1111.7)

>>             And what did I get?

>>  1111.7001

>>  I tried this on 2 microexplorers.  Can anyone
>>  duplicate this?  Is there another number that will
>>  exhibit the same bug/feature?  Don't ask me why I
>>  picked that number, I just did.  Help!

This is perfectly normal behaviour.  What may be confusing
you is that numbers like 1111.7 are REAL numbers in the
real world but not on any machine (that I know of).  They
are not REAL numbers, they are FLOATING POINT, fixed
precision numbers.  Unlike BIGNUMs, which are big enough
to represent the value needed with absolute precision,
FLOATS are subject to all sorts of rounding errors on the
last bit.  Don't forget also that, on Explorers, numbers
are represented in binary.  Because there is not a perfect
mapping between binary and base 10 representations you
will likely see some strange effects too.

I seem top recall that in Algol 68 it is, in fact, illegal
to compare two floating point values (A68 wrongly calls
them REALs) with the = operator, forcing you always to
state the tolerance that you believe to be adequate to
denote equality in your eyes.  I have a lot of sympathy
with this argument.  It seems pretty bogus to me that
(= 1 1.0).



Rice.

P.S.  If you aren't satisfied by this then you can always
force the FLOAT value to be represented as a double
precision value:

(print (setq number 1111.7D0))
1111.7d0 ;;; not 1111.7001
Technical Details
Message-ID: <2839778761-13258904@KSL-EXP-6>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!decwrl!ucbvax!SUMEX-AIM.STANFORD.EDU!Rice

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!decwrl!ucbvax!SUMEX-AIM.STANFORD.EDU!Rice
From: Rice@SUMEX-AIM.STANFORD.EDU (James Rice)
Newsgroups: comp.sys.ti.explorer
Subject: Re: Bug or Feature??
Message-ID: <2839778761-13258904@KSL-EXP-6>
Date: 27 Dec 89 19:26:01 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Distribution: inet
Organization: The Internet
Lines: 45