This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients mark.dickinson, r.david.murray, vstinner
Date 2022-02-04.20:55:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Manual test to check if m_nan(), _Py_dg_stdnan(0) and Py_NAN are exactly the same number (same bits):

$ ./python
>>> import math, struct
>>> m_nan=math.nan; Py_NAN=math.atan2(m_nan, 1.0)
>>> Py_NAN is m_nan
>>> struct.pack('d', m_nan) == struct.pack('d', Py_NAN)
>>> struct.pack('d', Py_NAN)

=> see attached script:

"struct.pack('d', m_nan) == struct.pack('d', Py_NAN)" is true with GH-31134 on Fedora 35 with gcc-11.2.1-7.fc35.x86_64. I tested with "gcc -O0" and "gcc -O3".

GCC float.h defines NAN with:

    #define NAN (__builtin_nanf (""))

GCC: "Built-in Function: double __builtin_nan (const char *str): This is an implementation of the ISO C99 function nan."
Date User Action Args
2022-02-04 20:55:44vstinnersetrecipients: + vstinner, mark.dickinson, r.david.murray
2022-02-04 20:55:44vstinnersetmessageid: <>
2022-02-04 20:55:44vstinnerlinkissue46640 messages
2022-02-04 20:55:44vstinnercreate