STINNER Victor <vstin...@python.org> added the comment:
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 False >>> struct.pack('d', m_nan) == struct.pack('d', Py_NAN) True >>> struct.pack('d', Py_NAN) b'\x00\x00\x00\x00\x00\x00\xf8\x7f' => see attached script: test_nan_bits.py "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." ---------- Added file: https://bugs.python.org/file50603/test_nan_bits.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46640> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com