Perhaps I'm doing something wrong: the struct module docs say
it's IEE 754, but I can't figure out how to get it to handle
NaN values correctly (either packing or unpacking).
[color=blue][color=green][color=darkred]
>>> x = float('nan')
>>> struct.pack("<f ",x)[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError: frexp() result out of range
[color=blue][color=green][color=darkred]
>>> struct.unpack(" <f",'\xff\xff\x ff\xff')[/color][/color][/color]
(-6.8056469327705 772e+38,)
I don't have my copy of 754 at hand, but I'm pretty sure that
0xffffffff is a NaN (printf on IA32 Linux agrees) and not
-6.8056469327705 772e+38 as claimed by struct.unpack() .
--
Grant Edwards grante Yow! Of course, you
at UNDERSTAND about the PLAIDS
visi.com in the SPIN CYCLE --
it's IEE 754, but I can't figure out how to get it to handle
NaN values correctly (either packing or unpacking).
[color=blue][color=green][color=darkred]
>>> x = float('nan')
>>> struct.pack("<f ",x)[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError: frexp() result out of range
[color=blue][color=green][color=darkred]
>>> struct.unpack(" <f",'\xff\xff\x ff\xff')[/color][/color][/color]
(-6.8056469327705 772e+38,)
I don't have my copy of 754 at hand, but I'm pretty sure that
0xffffffff is a NaN (printf on IA32 Linux agrees) and not
-6.8056469327705 772e+38 as claimed by struct.unpack() .
--
Grant Edwards grante Yow! Of course, you
at UNDERSTAND about the PLAIDS
visi.com in the SPIN CYCLE --
Comment