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. */
24 #define ASSERT(expr) \
29 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
39 ASSERT (!isnanl (3.141L));
40 ASSERT (!isnanl (3.141e30L));
41 ASSERT (!isnanl (3.141e-30L));
42 ASSERT (!isnanl (-2.718L));
43 ASSERT (!isnanl (-2.718e30L));
44 ASSERT (!isnanl (-2.718e-30L));
45 /* Infinite values. */
46 ASSERT (!isnanl (1.0L / 0.0L));
47 ASSERT (!isnanl (-1.0L / 0.0L));
49 ASSERT (isnanl (0.0L / 0.0L));
50 #if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT
54 ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
55 typedef union { long double value; unsigned int word[NWORDS]; }
58 m.value = 0.0L / 0.0L;
59 # if LDBL_EXPBIT0_BIT > 0
60 m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1);
62 m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
63 ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1);
65 m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
66 |= (unsigned int) 1 << LDBL_EXPBIT0_BIT;
67 ASSERT (isnanl (m.value));