Tim Peters <t...@python.org> added the comment:

It sounds like you need to read an introduction (any!) to computer 
floating-point formats.  The relevant part in the output you showed is this:

mant_dig=53

As on almost other current machines, your platform's floating point format is 
restricted to 53 bits of precision.  Therefore it's impossible to convert any 
positive integer to float without losing bits if the integer is of the form I * 
2**E where I is odd and I.bit_length() > 53.

That doesn't mean integers you can convert faithfully must be "small".  For 
example 2**200 can be converted to float exactly.  Apart from the 
power-of-2-exponent, that has only 1 significant bit.  You can also convert 
(2**52 + 1) * 2**200 to float exactly.  But NOT (2**53 + 1) * 2**200, because 
that requires 54 significant bits.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36934>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to