struct doesn't handle NaN values?
Grant Edwards
grante at visi.com
Thu May 13 15:44:59 EDT 2004
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).
>>> x = float('nan')
>>> struct.pack("<f",x)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError: frexp() result out of range
>>> struct.unpack("<f",'\xff\xff\xff\xff')
(-6.8056469327705772e+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.8056469327705772e+38 as claimed by struct.unpack().
--
Grant Edwards grante Yow! Of course, you
at UNDERSTAND about the PLAIDS
visi.com in the SPIN CYCLE --
More information about the Python-list
mailing list