in reply to int($x) gives strange result
Just like some numbers are periodic in decimal (1/3), some numbers are periodic in binary. 1.15 is one of them.
____ 1.15 (b10) = 1.0010010 (b2)
It can't be represented exactly as a float without infinite storage.
>perl -e"printf qq{%0.16e\n}, 1.15" 1.1499999999999999e+000
Previously mentioned sprintf "works" because it rounds instead of truncating.
|
|---|