1 /* Test of isnanl() substitute.
2 Copyright (C) 2007 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 2, or (at your option)
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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
23 #define ASSERT(expr) if (!(expr)) abort ();
29 ASSERT (!isnanl (3.141L));
30 ASSERT (!isnanl (3.141e30L));
31 ASSERT (!isnanl (3.141e-30L));
32 ASSERT (!isnanl (-2.718L));
33 ASSERT (!isnanl (-2.718e30L));
34 ASSERT (!isnanl (-2.718e-30L));
35 /* Infinite values. */
36 ASSERT (!isnanl (1.0L / 0.0L));
37 ASSERT (!isnanl (-1.0L / 0.0L));
39 ASSERT (isnanl (0.0L / 0.0L));
40 #if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT
44 ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
45 typedef union { long double value; unsigned int word[NWORDS]; }
48 m.value = 0.0L / 0.0L;
49 # if LDBL_EXPBIT0_BIT > 0
50 m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1);
52 m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
53 ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1);
55 m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
56 |= (unsigned int) 1 << LDBL_EXPBIT0_BIT;
57 ASSERT (isnanl (m.value));