how to convert 4 bytes into a float ?

Alex Martelli aleaxit at yahoo.com
Tue Feb 8 06:44:09 EST 2005


Jean-Baptiste PERIN <jb_perin at yahoo.fr> wrote:

> I'll have to handle Intel-PC, DEC-VAX and MIPS-SUN/SGI numbers
> So I can't escape the painful bit-twiddling

I don't recall for sure (even though I did my thesis on a Vax, 25 years
ago!) but I think you _might_ be lucky -- VAX used the binary format
that became the IEEE standard, if I recall correctly.

Intel, MIPS, SUN and SGI surely did follow IEEE standards, endianity
apart, and you can correct for endianity with struct.unpack.

The problem would be there if you had, say, floats in old IBM 360/370
formats, or Cray's original formats, or the like...

 
> Anyway, struct.unpack will undoubtedly be an incredibly valuable help
> 
> thank you very very very much ..

You're welcome!


Alex



More information about the Python-list mailing list