Help need with converting Hex string to IEEE format float
Max M
maxm at mxm.dk
Tue Dec 14 11:18:49 EST 2004
i_vincent at hotmail.com wrote:
> Each of these numbers is a Hex byte making up a four byte (32 bit
> Big-Endian) IEEE float. I have read this data into Python using
> readlines and then line.split(). This gives me:
>
> ['80', '00', '00', '00']
Oh, programmers loves this kind stuff. You should get tons of answers.
##
st = '80 00 00 00'
import binascii
import struct
s = ''.join([binascii.a2b_hex(s) for s in st.split()])
v = struct.unpack("f", s)[0]
print v
##
regards Max M
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Python-list
mailing list