## When is NaN not a number with Python 2.4?

Posted by Nick Joyce | Filed under ieee754, struct, double, float, nan, python2.4, AMF

From Wikipedia:

The

IEEE Standard for Binary Floating-Point Arithmetic(IEEE 754) is the most widely-used standard for floating-point computation, and is followed by many CPU and FPU implementations.

Included in this specification is the ability to denote intangible numbers such as positive and negative infinity, and NaN (Not a Number). A floating point number is represented either by 32 or 64 bits (depending on how much precision you require). These bits are split up into 3 sections: a fraction, an exponent and a signed bit. More information on the structure of the floating point numbers can be found on Wikipedia.

We use EchoTest against PyAMF to ensure that what is sent to the server is returned verbatim, this way we can check things like data types, references, class mappings etc. We generally use Python 2.5 to run the server but Thijs Triemstra noticed that some numeric tests were failing when using Python 2.4, specifically NaN.