Formatting a nan float in python

Viewed 3332

I'm trying to use string.format on a 'nan' float.

Here's the description of the 'g' option from the python documentation.

General format. This prints the number as a fixed-point number, unless the number is too large, in which case it switches to 'e' exponent notation. Infinity and NaN values are formatted as inf, -inf and nan, respectively.

And here's what i get trying it in the interpreter (Python 2.6):

>>> print "{0:g}".format(float('nan'))
-1.#IND

As I understand the documentation, the output should be "nan".

Is this a bug or am I doing it wrong?

1 Answers
Related