1 /* Test of isnanl() substitute.
2 Copyright (C) 2007-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
22 #include "minus-zero.h"
32 ASSERT (!isnanl (3.141L));
33 ASSERT (!isnanl (3.141e30L
));
34 ASSERT (!isnanl (3.141e-30L));
35 ASSERT (!isnanl (-2.718L));
36 ASSERT (!isnanl (-2.718e30L
));
37 ASSERT (!isnanl (-2.718e-30L));
38 ASSERT (!isnanl (0.0L));
39 ASSERT (!isnanl (minus_zerol
));
40 /* Infinite values. */
41 ASSERT (!isnanl (Infinityl ()));
42 ASSERT (!isnanl (- Infinityl ()));
44 ASSERT (isnanl (NaNl ()));
47 ASSERT (isnanl (SNaNl ()));
50 #if ((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
51 /* Representation of an 80-bit 'long double' as an initializer for a sequence
52 of 'unsigned int' words. */
53 # ifdef WORDS_BIGENDIAN
54 # define LDBL80_WORDS(exponent,manthi,mantlo) \
55 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
56 ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \
57 (unsigned int) (mantlo) << 16 \
60 # define LDBL80_WORDS(exponent,manthi,mantlo) \
61 { mantlo, manthi, exponent }
64 static memory_long_double x
=
65 { .word
= LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
66 ASSERT (isnanl (x
.value
));
70 static memory_long_double x
=
71 { .word
= LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
72 ASSERT (isnanl (x
.value
));
74 /* isnanl should return something for noncanonical values. */
76 static memory_long_double x
=
77 { .word
= LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
78 ASSERT (isnanl (x
.value
) || !isnanl (x
.value
));
80 { /* Pseudo-Infinity. */
81 static memory_long_double x
=
82 { .word
= LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
83 ASSERT (isnanl (x
.value
) || !isnanl (x
.value
));
86 static memory_long_double x
=
87 { .word
= LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
88 ASSERT (isnanl (x
.value
) || !isnanl (x
.value
));
90 { /* Unnormalized number. */
91 static memory_long_double x
=
92 { .word
= LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
93 ASSERT (isnanl (x
.value
) || !isnanl (x
.value
));
95 { /* Pseudo-Denormal. */
96 static memory_long_double x
=
97 { .word
= LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
98 ASSERT (isnanl (x
.value
) || !isnanl (x
.value
));
103 return test_exit_status
;