struct doesn't handle NaN values?
John Roth
newsgroups at jhrothjr.com
Thu May 13 16:18:10 EDT 2004
More information about the Python-list mailing list
Thu May 13 16:18:10 EDT 2004
- Previous message (by thread): struct doesn't handle NaN values?
- Next message (by thread): struct doesn't handle NaN values?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Grant Edwards" <grante at visi.com> wrote in message news:slrnca7k1l.an4.grante at grante.rivatek.com... > 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(). I believe that struct uses the c library as is, like the float support in general. Unfortunately, that leaves everyone at the mercy of the rather inconsistent and ideosyncratic implementations of corner cases in existing c libraries. See PEP 754 for a discussion of the issues. John Roth > > -- > Grant Edwards grante Yow! Of course, you > at UNDERSTAND about the PLAIDS > visi.com in the SPIN CYCLE --
- Previous message (by thread): struct doesn't handle NaN values?
- Next message (by thread): struct doesn't handle NaN values?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list