Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Perl does an internal magic error correction/guessing when printing a number like 195.999999...etc to compensate rounding errors on the last digits. (This of course in binary and not decimal representation)
I think that's why it prints $x1 as 196. I'll check as soon my laptop is up and running.
updateas I thought, it's compensating the rounding error from not being able to accurately represent 0.15 in a based 2 floating number:
There is an easy workaround , avoid the decimal point when calculating and divide at the very end.
see also Humans have too many fingers
Cheers Rolf In reply to Re: int() function (updated)
by LanX
|
|