Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!news.kei.com!bloom-beacon.mit.edu!spool.mu.edu!howland.reston.ans.net!swrinde!cam.news.pipex.net!pipex!edi.news.pipex.net!pipex!oleane!jussieu.fr!math.ohio-state.edu!news.cyberstore.ca!skypoint.com!news3.mr.net!mr.net!medtronic.com!rosevax!news
From: wirwin@frmail.frco.com (Will Irwin)
Subject: Re: Rounding Error in Digitalk 3.0.1
X-Nntp-Posting-Host: stpc11
Message-ID: <1995Jun22.043208.17330@rosevax.rosemount.com>
Sender: news@rosevax.rosemount.com (Rosevax USENET News auto-admin account)
Reply-To: wirwin@frmail.frco.com
Organization: Fisher-Rosemount
X-Newsreader: Forte Free Agent v0.46
References: <3s6aa2$ssn@raffles.technet.sg> <1995Jun20.182314.24571@medicus.com>
Date: Thu, 22 Jun 1995 04:37:54 GMT
Lines: 45

billf@medicus.com (Bill Foote) wrote:

>In article <3s6aa2$ssn@raffles.technet.sg> UserName <user@technet.sg> writes:
>>I have had this experience in Digitalk 3.0.1
>>
>>0.025 printRounded:2 => 0.03
>>1.025 printRounded:2 => 1.02
>>
>>Looks like a bug to me. 
>>Has anyone encountered this shared with me how to fix it ?
>>
>>Looks like a bug to me. 

>No, it's not.

[ Good explaination of why it's not a bug deleted ]

[ Example of the same thing in C deleted ]

>The moral?  Be very careful when using floats, and never, *ever* use them
>to represent money.  You have been warned :-)

Amen to that!

Two comments on this issue:

	Don't they teach this kind of thing in Computer Science courses these
	days?  This question seems to come up with astonishing frequency 
	(it's only a couple of weeks ago that someone lambasted Parcplace
	for exactly the same non-bug).  Surely anyone taught to program a
	computer needs to understand this fundamental point about how
	floating point numbers are represented, but I keep coming across
	people who don't know it.

	Why does it come up more frequently in Smalltalk discussions than
	elsewhere?  Admittedly I only read comp.lang.c or comp.lang.c++ when
	I really can't avoid it, but my impression is that it is more 
	prevalent in c.l.s.


Will Irwin
wirwin@frmail.frco.com (work)
irwin@singnet.com.sg (home)
Singapore

