how to convert 3 byte to float

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sat Dec 8 06:06:57 EST 2007


Mario M. Mueller wrote:
> I have a binary file containing 3 byte float values (big endian).
> How can I read them into python? The struct module does not work,
> since it expects 4 byte floats.

Since the module crystalball is still in development, you'll have to
analyze your three byte float format and convert it either to a
IEEE 754 "single" float and use struct, or convert manually using
bitwise operators.

BTW, who in his mind designs three byte floats? Memory isn't that
expensive anymore. Even C bool is four bytes long.

Regards,


Björn

-- 
BOFH excuse #87:

Password is too complex to decrypt




More information about the Python-list mailing list