in reply to Re: Behaviour of int() unexpected
in thread Behaviour of int() unexpected
The way I like to explain it is that 895/100 is periodic in binary (and hex), just like 1/3 is periodic in decimal. (That's why you see the repeating 6s.) As such, storing it accurately as a floating point number would take infinite amount of storage. The closest floating point number is used instead. In this case, that's 0x1.1E66666666666 * 2^3 = 8.949999999999999289457264239899814128875732421875.
|
|---|