
On Sun, Apr 20, 2014 at 5:12 PM, Chapman, Anthony Sergio < a.s.chapman.10@aberdeen.ac.uk> wrote:
I would it to round to 2 decimal places no matter what the size of the input is
ei toPerc 0.22222222222222 --- = 22.22 toPerc 0.22342222222222 --- = 22.34
The problem is that what I actually get is 22.220000000000002
Looks like typical floating point behavior to me. The last place can't be precisely controlled because you are printing in base 10 but the internal format (as defined by the CPU) is base 2 and very few base 10 decimals have exact base 2 representations. This is not a bug (unless you consider the existence of floating point to be a bug) and cannot be "fixed". -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net