Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!torn!nott!cunews!tina.mrco.carleton.ca!knight
From: knight@mrco.carleton.ca (Alan Knight)
Subject: Re: Substraction Problems :-(
Message-ID: <knight.794252361@tina.mrco.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Reply-To: knight@mrco.carleton.ca (Alan Knight)
Organization: Carleton University
References: <3ivu79$hsc@panix3.panix.com> <3j5kh2$a6f@news1.delphi.com>
Date: Fri, 3 Mar 1995 17:39:21 GMT
Lines: 37

In <3j5kh2$a6f@news1.delphi.com> jsutherland@BIX.com (Jeff Sutherland) writes:
>I think that at one of the first ANSI Smalltalk meetings they addressed the
>floating point issue.  When they sat down and tried it on their laptops,
>ENFIN and Digitalk came up with the right answer and ParcPlace had this
>problem.

>Anyway, in ENFIN Smalltalk, 100.9 -100.0 returns 0.9

It seems people are very easily fooled by appearances. It's not that
Digitalk and Easel get the "right" answer, it's that they truncate the
number of digits on the "wrong" answer so that it looks right. Try the
following expressions

(100.9 - 100.0) = 0.9
((100.9 - 100.0) - 0.9)

They produce false and non-zero respectively on all 3 implementations.
I don't have a Mac, so I couldn't try SmalltalkAgents, but I'd bet
money it's the same.

Also, Digitalk and Easel only support double-precision floats, whereas
ParcPlace supports both single and double precision, with single the
default. Thus the number of significant digits on ParcPlace is smaller
by default. (Of course you can change the default, and somebody
already posted a mechanism to do that).

I'm not sure if it's a feature or not to truncate floating point
numbers so that the initial approximation errors don't show up. It
makes things more convenient, but seems to let people (including a
number of vendor representatives) continue in their belief that
these errors don't happen.

-- 
 Alan Knight                | The Object People
 knight@acm.org             | Smalltalk and OO Training and Consulting
 alan_knight@mindlink.bc.ca | 509-885 Meadowlands Dr.
 +1 613 225 8812            | Ottawa, Canada, K2C 3N2
