[Pharo-project] Unexpected behavior of roundTo:

Stéphane Ducasse stephane.ducasse at inria.fr
Sat Apr 9 09:02:25 CEST 2011


Nicolas

would not you like the write (I can help) a two three 5 pages document
for the next book on this topics? :)

I would be gorgeous and everybody would love that

Stef

On Apr 8, 2011, at 7:18 PM, Nicolas Cellier wrote:

> Yes nice example to exhibit in school
> 
> This again happens even if performed exactly (then rounded to nearest Float)
> (2.8 asTrueFraction roundTo: 0.01 asTrueFraction) asFloat
> 
> As soon as you write 0.01 instead of (1/100) or (0.01s2), the worm is
> in the fruit.
> 
> Nicolas
> 
> 2011/4/8 Hilaire Fernandes <hilaire.fernandes at gmail.com>:
>> Even better:
>> 
>> 2.8 truncateTo: 0.01
>> -> 2.8000000000000003
>> 
>> 
>> Le 08/04/2011 18:52, Hilaire Fernandes a écrit :
>>> It looks like a known issue:
>>> 
>>> printShowingDecimalPlaces: placesDesired
>>>       "This implementation avoids any rounding error caused by rounded or
>>> roundTo: "
>>>       ^ self asTrueFraction printShowingDecimalPlaces: placesDesired
>>> 
>>> 
>>> 
>>> Le 08/04/2011 18:47, Hilaire Fernandes a écrit :
>>>> 2.8011416510246336 roundTo: 0.01
>>>> 
>>>> returns
>>>> 
>>>>  2.8000000000000003
>>>> 
>>>> 
>>>> Tested with 1.2
>>>> 
>>>> 
>>>> Should I fill a ticket, I don't see anythings similar?
>>>> 
>>>> Hilaire
>>>> 
>>> 
>>> 
>> 
>> 
>> --
>> Education 0.2 -- http://blog.ofset.org/hilaire
>> 
>> 
>> 
> 




More information about the Pharo-project mailing list