diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
| commit | cfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch) | |
| tree | 8016486f8ee7157213f2d09ff2491bfa9c94638a /lib/isnan.c | |
| parent | 14e4d584d0121031ec40e6c35869745f1747ff29 (diff) | |
| parent | 1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff) | |
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
Diffstat (limited to 'lib/isnan.c')
| -rw-r--r-- | lib/isnan.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/isnan.c b/lib/isnan.c index c7d84e8d..491dc6dc 100644 --- a/lib/isnan.c +++ b/lib/isnan.c @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2024 Free Software Foundation, Inc. + Copyright (C) 2007-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -105,10 +105,8 @@ FUNC (DOUBLE x) The NaN bit pattern is: - exponent = 0x7FFF, mantissa >= 0x8000000000000001. */ memory_double m; - unsigned int exponent; - m.value = x; - exponent = (m.word[EXPBIT0_WORD] >> EXPBIT0_BIT) & EXP_MASK; + unsigned int exponent = (m.word[EXPBIT0_WORD] >> EXPBIT0_BIT) & EXP_MASK; # ifdef WORDS_BIGENDIAN /* Big endian: EXPBIT0_WORD = 0, EXPBIT0_BIT = 16. */ if (exponent == 0) @@ -130,19 +128,17 @@ FUNC (DOUBLE x) /* Be careful to not do any floating-point operation on x, such as x == x, because x may be a signaling NaN. */ # if defined __SUNPRO_C || defined __ICC || defined _MSC_VER \ - || defined __DECC || defined __TINYC__ \ - || (defined __sgi && !defined __GNUC__) + || defined __DECC || defined __TINYC__ /* The Sun C 5.0, Intel ICC 10.0, Microsoft Visual C/C++ 9.0, Compaq (ex-DEC) 6.4, and TinyCC compilers don't recognize the initializers as constant expressions. The Compaq compiler also fails when constant-folding 0.0 / 0.0 even when constant-folding is not required. The Microsoft Visual C/C++ compiler also fails when constant-folding 1.0 / 0.0 even - when constant-folding is not required. The SGI MIPSpro C compiler - complains about "floating-point operation result is out of range". */ + when constant-folding is not required. */ static DOUBLE zero = L_(0.0); - memory_double nan; DOUBLE plus_inf = L_(1.0) / zero; DOUBLE minus_inf = -L_(1.0) / zero; + memory_double nan; nan.value = zero / zero; # else static memory_double nan = { L_(0.0) / L_(0.0) }; @@ -151,15 +147,15 @@ FUNC (DOUBLE x) # endif { memory_double m; + m.value = x; /* A NaN can be recognized through its exponent. But exclude +Infinity and -Infinity, which have the same exponent. */ - m.value = x; if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD]) & (EXP_MASK << EXPBIT0_BIT)) == 0) - return (memcmp (&m.value, &plus_inf, SIZE) != 0 - && memcmp (&m.value, &minus_inf, SIZE) != 0); + return (!memeq (&m.value, &plus_inf, SIZE) + && !memeq (&m.value, &minus_inf, SIZE)); else return 0; } @@ -173,13 +169,14 @@ FUNC (DOUBLE x) # if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Detect any special bit patterns that pass ==; see comment above. */ memory_double m1; - memory_double m2; - memset (&m1.value, 0, SIZE); - memset (&m2.value, 0, SIZE); m1.value = x; + + memory_double m2; + memset (&m2.value, 0, SIZE); m2.value = x + (x ? 0.0L : -0.0L); - if (memcmp (&m1.value, &m2.value, SIZE) != 0) + + if (!memeq (&m1.value, &m2.value, SIZE)) return 1; # endif return 0; |
