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 /Python/dtoa.c | |
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 'Python/dtoa.c')
-rw-r--r-- | Python/dtoa.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/Python/dtoa.c b/Python/dtoa.c index 6ea60ac..c5e343b 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -273,11 +273,6 @@ typedef union { double d; ULong L[2]; } U; #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) #define Big1 0xffffffff -/* Standard NaN used by _Py_dg_stdnan. */ - -#define NAN_WORD0 0x7ff80000 -#define NAN_WORD1 0 - /* Bits of the representation of positive infinity. */ #define POSINF_WORD0 0x7ff00000 @@ -1399,35 +1394,6 @@ bigcomp(U *rv, const char *s0, BCinfo *bc) return 0; } -/* Return a 'standard' NaN value. - - There are exactly two quiet NaNs that don't arise by 'quieting' signaling - NaNs (see IEEE 754-2008, section 6.2.1). If sign == 0, return the one whose - sign bit is cleared. Otherwise, return the one whose sign bit is set. -*/ - -double -_Py_dg_stdnan(int sign) -{ - U rv; - word0(&rv) = NAN_WORD0; - word1(&rv) = NAN_WORD1; - if (sign) - word0(&rv) |= Sign_bit; - return dval(&rv); -} - -/* Return positive or negative infinity, according to the given sign (0 for - * positive infinity, 1 for negative infinity). */ - -double -_Py_dg_infinity(int sign) -{ - U rv; - word0(&rv) = POSINF_WORD0; - word1(&rv) = POSINF_WORD1; - return sign ? -dval(&rv) : dval(&rv); -} double _Py_dg_strtod(const char *s00, char **se) |