[Newbies] Problem with roundTo: (Actually with *)
Bert Freudenberg
bert at freudenbergs.de
Wed Jul 3 21:17:23 UTC 2013
On 03.07.2013, at 13:56, summae3443 at mypacks.net wrote:
> In Squeak 4.3 I print "(7/5) roundTo: 0.01" and get "1.4"
> however,
> In Squeak 4.4 I print "(7/5) roundTo: 0.01" and get "1.4000000000000001"
>
> Am I doing something to cause this change? Or, is this the result of inflation :)
No, it's the result of more precise Float printing. Consider this:
((7/5) roundTo: 0.01) = 1.4
==> false
((7/5) roundTo: 0.01) = 1.4000000000000001
==> true
For printing with a reduced precision you should not use roundTo but this:
7/5 printShowingDecimalPlaces: 2
==> '1.40'
7/5 printShowingMaxDecimalPlaces: 2
==> '1.4'
- Bert -
More information about the Beginners
mailing list