IEEE 754 float representation of a number

sismex01 at hebmex.com sismex01 at hebmex.com
Mon Dec 9 09:50:20 EST 2002


> From: bob_tommy at hotmail.com [mailto:bob_tommy at hotmail.com]
> Sent: Monday, December 09, 2002 8:39 AM
> 
> hmmm. Expected the line 
> struct.pack('>f',3.04) to return these four bytes:
> 
> '\x40\x42\x8f\x5c' (IEEE 754 format)
> 
> but instead 
> 
> '@B\x8f\\' was returned.
> 
> What have I missed here??? 
> Very grateful for any help!
>

Well, nothing wrong happened! Look here:

>>> '\x40\x42\x8f\x5c'
'@B\x8f\\'
>>> 

So, '\x40' == '@'
    '\x42' == 'B'
    '\x5c' == '\\'

-gus




More information about the Python-list mailing list