Binary Decimals in Python
invalid at invalid.invalid
Tue Mar 30 20:08:14 CEST 2010
On 2010-03-30, John Nagle <nagle at animats.com> wrote:
> Hex floats are useful because you can get a string representation of
> the exact value of a binary floating point number. It should always
> be the case that
> float.fromhex(float.hex(x)) == x
Until you try running your program on a machine that represents floats
using a radix other than 2,4, or 16.
And it works for NaN and Inf too!
It would have been nice to have had that 5-6 years ago when I had to
write my own pickle/unpickle methods for floating point values so that
inf and nan were portable between Windows and Linux.
Grant Edwards grant.b.edwards Yow! But they went to MARS
at around 1953!!
More information about the Python-list