mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-16 01:22:18 +03:00
* build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
66 lines
2.1 KiB
C
66 lines
2.1 KiB
C
/* Test of isnanf() substitute.
|
|
Copyright (C) 2007-2017 Free Software Foundation, Inc.
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
|
|
|
|
#include <limits.h>
|
|
|
|
#include "minus-zero.h"
|
|
#include "infinity.h"
|
|
#include "nan.h"
|
|
#include "macros.h"
|
|
|
|
int
|
|
main ()
|
|
{
|
|
/* Finite values. */
|
|
ASSERT (!isnanf (3.141f));
|
|
ASSERT (!isnanf (3.141e30f));
|
|
ASSERT (!isnanf (3.141e-30f));
|
|
ASSERT (!isnanf (-2.718f));
|
|
ASSERT (!isnanf (-2.718e30f));
|
|
ASSERT (!isnanf (-2.718e-30f));
|
|
ASSERT (!isnanf (0.0f));
|
|
ASSERT (!isnanf (minus_zerof));
|
|
/* Infinite values. */
|
|
ASSERT (!isnanf (Infinityf ()));
|
|
ASSERT (!isnanf (- Infinityf ()));
|
|
/* Quiet NaN. */
|
|
ASSERT (isnanf (NaNf ()));
|
|
#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT
|
|
/* Signalling NaN. */
|
|
{
|
|
#define NWORDS \
|
|
((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
|
|
typedef union { float value; unsigned int word[NWORDS]; } memory_float;
|
|
memory_float m;
|
|
m.value = NaNf ();
|
|
# if FLT_EXPBIT0_BIT > 0
|
|
m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1);
|
|
# else
|
|
m.word[FLT_EXPBIT0_WORD + (FLT_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)]
|
|
^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1);
|
|
# endif
|
|
if (FLT_EXPBIT0_WORD < NWORDS / 2)
|
|
m.word[FLT_EXPBIT0_WORD + 1] |= (unsigned int) 1 << FLT_EXPBIT0_BIT;
|
|
else
|
|
m.word[0] |= (unsigned int) 1;
|
|
ASSERT (isnanf (m.value));
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|