struct, IEEE-754 and internal representation

jepler at unpythonic.net jepler at unpythonic.net
Wed Nov 9 18:37:38 EST 2005


Use 'd' as the format character for 64-bit double precision numbers with struct.

>>> x = 148.73
>>> unpack("<d", pack("<d", x))[0] == x
True
>>> unpack("<f", pack("<f", x))[0] == x
False

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051109/48dd921e/attachment.sig>


More information about the Python-list mailing list