diff options
author | Sebastian Berg <sebastianb@nvidia.com> | 2023-05-10 16:44:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 16:44:52 (GMT) |
commit | 7a3b03509e5e3e72d8c47137579cccb52548a318 (patch) | |
tree | cbb1adddb46665552cb1e93ccae135aac0507e80 /Objects | |
parent | a7a2dbbf72aceef61bfb50901bfa39bfb8d6d229 (diff) | |
download | cpython-7a3b03509e5e3e72d8c47137579cccb52548a318.zip cpython-7a3b03509e5e3e72d8c47137579cccb52548a318.tar.gz cpython-7a3b03509e5e3e72d8c47137579cccb52548a318.tar.bz2 |
gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)
This PR removes `_Py_dg_stdnan` and `_Py_dg_infinity` in favour of
using the standard `NAN` and `INFINITY` macros provided by C99.
This change has the side-effect of fixing a bug on MIPS where the
hard-coded value used by `_Py_dg_stdnan` gave a signalling NaN
rather than a quiet NaN.
---------
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index d257857..83a263c 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -2424,25 +2424,14 @@ PyFloat_Unpack2(const char *data, int le) f |= *p; if (e == 0x1f) { -#if _PY_SHORT_FLOAT_REPR == 0 if (f == 0) { /* Infinity */ return sign ? -Py_HUGE_VAL : Py_HUGE_VAL; } else { /* NaN */ - return sign ? -Py_NAN : Py_NAN; + return sign ? -fabs(Py_NAN) : fabs(Py_NAN); } -#else // _PY_SHORT_FLOAT_REPR == 1 - if (f == 0) { - /* Infinity */ - return _Py_dg_infinity(sign); - } - else { - /* NaN */ - return _Py_dg_stdnan(sign); - } -#endif // _PY_SHORT_FLOAT_REPR == 1 } x = (double)f / 1024.0; |