[Tutor] int(1.99...99) = 1 and can = 2
boB Stepp
robertvstepp at gmail.com
Sun May 1 02:02:50 EDT 2016
Life has kept me from Python studies since March, but now I resume.
Playing around in the interpreter I tried:
py3: 1.9999999999999999
2.0
py3: 1.999999999999999
1.999999999999999
py3: int(1.9999999999999999)
2
py3: int(1.999999999999999)
1
It has been many years since I did problems in converting decimal to
binary representation (Shades of two's-complement!), but I am under
the (apparently mistaken!) impression that in these 0.999...999
situations that the floating point representation should not go "up"
in value to the next integer representation. This is acting like in
the case of 15 nines the final bit is "0", but with 16 nines it is
"1". Would someone clarify this for me, please?
--
boB
More information about the Tutor
mailing list