[squeak-dev] Float rounding issue
Bert Freudenberg
bert at freudenbergs.de
Mon May 7 09:51:52 UTC 2012
On 07.05.2012, at 01:17, Chris Muller wrote:
> With the latest trunk updates, I'm having trouble rounding to my
> desired precision:
>
> 0.9580000000000001 roundTo: 0.0001 " 0.9580000000000001"
>
> In Squeak 4.3 I get what I expect:
>
> 0.9580000000000001 roundTo: 0.0001 " 0.958"
>
Most likely, what you really want is this:
0.9580000000000001 printShowingDecimalPlaces: 4
==> '0.9580'
However, we don't seem to have a method that would leave out the unnecessary trailing zeroes.
And printShowingDecimalPlaces: does not take negative arguments (but roundTo: with integer arguments is good enough for that).
- Bert -
More information about the Squeak-dev
mailing list
|