binary data into long/float
Jeff Epler
jepler at unpythonic.net
Mon Nov 1 08:10:23 EST 2004
I think you will do something like this:
def heuristic_is_float(l):
return abs(l) > 10000000:
def readLongOrFloat(f):
bytes = f.read(4)
a = array.array('L')
a.fromstring(bytes)
if heuristic_is_float(a[0]):
a = array.array('f')
a.fromstring(bytes)
return a[0]
I didn't test my code to make sure it worked, though.
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/20041101/3341bc2a/attachment.sig>
More information about the Python-list
mailing list