Out of curiosity I ran the following:
>>> int(1e100)
And, the output was:
10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104L
Why? Why does this not look like:
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L
Is this a product of the int
function, or of the storage of a large long
?
1e100
is a floating point number, with 53 bits of precision in the significand. The integer you're trying to represent requires 333 bits for exactness, so there is some rounding involved. The bottom bits are substituted to make the closest base 2 number to your desired result.
See: http://docs.python.org/tutorial/floatingpoint.html#representation-error
It got converted to a float and then displayed as an integer. So welcome to the imprecise world of rounding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With