[squeak-dev] The joys (or not) of floating point numbers

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Mar 26 17:59:12 UTC 2013


2013/3/26 Louis LaBrunda <Lou at keystone-software.com>:
> On Tue, 26 Mar 2013 18:32:31 +0100, Stéphane Rollandin
> <lecteur at zogotounga.net> wrote:
>
>>> Example (0.995 round: 2) -> 1.00 though 0.995 < (995/1000) so it
>>> should round to 0.99.
>>
>>.. and I just noticed that
>>
>>       0.995 printShowingDecimalPlaces: 2   ==>  '1.00'
>>
>>Do we have a method returning the correct value ?
>
> That looks right to me, because 0.995 was rounded up.
>
> Lou

No it's not, because 0.995 < 0.995s3 so it should be rounded down.
In a recent trunk image, print is OK:
(0.995 printShowingDecimalPlaces: 2) ->  '0.99'

Nicolas


> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com
>
>


More information about the Squeak-dev mailing list