Message412538
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." |
|
Date |
User |
Action |
Args |
2022-02-04 20:55:44 | vstinner | set | recipients:
+ vstinner, mark.dickinson, r.david.murray |
2022-02-04 20:55:44 | vstinner | set | messageid: <1644008144.24.0.578316880975.issue46640@roundup.psfhosted.org> |
2022-02-04 20:55:44 | vstinner | link | issue46640 messages |
2022-02-04 20:55:44 | vstinner | create | |
|