[Pharo-project] Unexpected behavior of roundTo:

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri Apr 8 19:18:16 CEST 2011


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