help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] More odd float results


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] More odd float results
Date: Wed, 08 Nov 2006 08:56:56 +0100
User-agent: Thunderbird 1.5.0.7 (Macintosh/20060909)

J Pfersich wrote:
I got this...

st> var1 := 20 - 2.2325251 !
17.7674749000000
st> var1 printNl !
17.7674748999999
17.7674749000000

I know that the result isn't far off, but why didn't it round up to 17.7674749?
It's actually wrong:

st> ('17.7674748999999' asNumber = Var1)!
false
st> ('17.7674749000000' asNumber = Var1)!
true

Now that fast LargeIntegers are part of the system it's actually possible to write a better (and still simple) algorithm to print floats.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]