/Sébastien Boisgérault wrote:/

> But, practically, I have never found a platform where
> the following fpconst-like code did not work:
>
> import struct
> cast = struct.pack
>
> big_endian = cast('i',1)[0] != '\x01'
> if big_endian:
>    nan = cast('d', '\x7F\xF8\x00\x00\x00\x00\x00\x00')[0]
> else:
>    nan = cast('d', '\x00\x00\x00\x00\x00\x00\xf8\xff')[0]

Exactly this code doesn't work. When executing it I get the error message:

Traceback (most recent call last):
  File "float_tools.py", line 8, in ?
    nan = cast('d', '\x00\x00\x00\x00\x00\x00\xf8\xff')[0]
error: required argument is not a float

Maybe the second line should read:
cast = struct.unpack

However, the actual fpconst.py works fine.

Thanks for the hints,
   Andreas

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to