mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-23 11:20:07 +00:00
5ce98c3f3f
2004-05-03 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/bsd/bits/fcntl.h (F_SETOWN, F_GETOWN): Define if __USE_BSD or __USE_UNIX98. * sysdeps/unix/bsd/ultrix4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/bsd/bsd4.4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/common/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/aix/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/irix4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/s390/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/cris/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. *sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/mips/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/sh/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/i386/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/m68k/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/arm/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/hppa/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/generic/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/mach/hurd/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * io/sys/stat.h (S_ISSOCK, S_IFSOCK): Likewise. 2004-05-01 Jakub Jelinek <jakub@redhat.com> * posix/Versions (libc): Remove __libc_wait, __libc_waitpid, __libc_pause, __libc_nanosleep, __libc_pread, __libc_pread64, __libc_pwrite64, __waitid and __pselect @@GLIBC_PRIVATE. * stdlib/Versions (libc): Remove __on_exit@@GLIBC_PRIVATE. * sysdeps/unix/sysv/linux/Versions (libc): Remove __libc_sigaction@@GLIBC_PRIVATE. * sysdeps/unix/sysv/linux/x86_64/Versions (libc): Remove __modify_ldt@@GLIBC_PRIVATE. * socket/Versions (libc): Remove __libc_accept, __libc_send, __libc_recvfrom, __libc_recvmsg, __libc_sendmsg, __libc_recv, __libc_sendto and __libc_connect @@GLIBC_PRIVATE. * stdio-common/Versions (libc): Remove _itoa_upper_digits@@GLIBC_PRIVATE. * resolv/Versions (libresolv): Remove __ns_samename@@GLIBC_PRIVATE. * misc/Versions (libc): Remove __libc_fsync, __libc_msync, __libc_readv and __libc_writev @@GLIBC_PRIVATE. * termios/Versions (libc): Remove __libc_tcdrain@@GLIBC_PRIVATE. * io/Versions (libc): Remove __libc_open, __libc_close, __libc_read, __libc_write, __libc_lseek, __libc_fcntl, __libc_open64 and __libc_lseek64 @@GLIBC_PRIVATE. 2004-04-30 Jakub Jelinek <jakub@redhat.com> * elf/dl-load.c (open_verify): Move e_phentsize check after e_type check. 2004-04-29 Steven Munroe <sjmunroe@us.ibm.com> * sysdeps/powerpc/powerpc64/fpu/s_ceil.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_floor.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_floorf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llrint.c: Removed. * sysdeps/powerpc/powerpc64/fpu/s_llrint.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llrintf.c: Removed. * sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llround.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llroundf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_lround.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_lroundf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_rint.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_rintf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_round.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_roundf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_trunc.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_truncf.S: New file. * math/test-misc.c [LDBL_MANT_DIG == 106](main): Correct LDBL_MAX mantissa for AIX long double format. * misc/qefgcvt.c [LDBL_MANT_DIG == 106] (NDIGIT_MAX): Define for AIX long double format. * misc/qefgcvt_r.c [LDBL_MANT_DIG == 106] (NDIGIT_MAX): Likewise. * stdlib/fpioconst.c [!__NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__>1024] (_fpioconst_pow10): AIX long double format has same exponent range as double. * stdlib/fpioconst.h [!__NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__>1024] (LDBL_MAX_10_EXP_LOG): AIX long double format has same exponent range as double. 2004-04-23 Art Haas <ahaas@airmail.net> * sysdeps/unix/sysv/linux/kernel-features.h: Add 'defined'.
1148 lines
29 KiB
C
1148 lines
29 KiB
C
/* Miscellaneous tests which don't fit anywhere else.
|
|
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#include <fenv.h>
|
|
#include <float.h>
|
|
#include <ieee754.h>
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int result = 0;
|
|
|
|
#ifndef NO_LONG_DOUBLE
|
|
{
|
|
long double x = 0x100000001ll + (long double) 0.5;
|
|
long double q;
|
|
long double r;
|
|
|
|
r = modfl (x, &q);
|
|
if (q != (long double) 0x100000001ll || r != 0.5)
|
|
{
|
|
printf ("modfl (%Lg, ...) failed\n", x);
|
|
result = 1;
|
|
}
|
|
}
|
|
|
|
# if __GNUC__ >= 3 || __GNUC_MINOR__ >= 96
|
|
{
|
|
long double x;
|
|
long double m;
|
|
long double r;
|
|
int e;
|
|
int i;
|
|
|
|
# if LDBL_MANT_DIG == 64
|
|
m = 0xf.fffffffffffffffp-4L;
|
|
# elif LDBL_MANT_DIG == 106
|
|
/* This has to match the mantissa of LDBL_MAX which actually does have a
|
|
missing bit in the middle. */
|
|
m = 0x1.fffffffffffff7ffffffffffff8p-1L;
|
|
# elif LDBL_MANT_DIG == 113
|
|
m = 0x1.ffffffffffffffffffffffffffffp-1L;
|
|
# else
|
|
# error "Please adjust"
|
|
# endif
|
|
|
|
for (i = LDBL_MAX_EXP, x = LDBL_MAX; i >= LDBL_MIN_EXP; --i, x /= 2.0L)
|
|
{
|
|
printf ("2^%d: ", i);
|
|
|
|
r = frexpl (x, &e);
|
|
if (r != m)
|
|
{
|
|
printf ("mantissa incorrect: %.20La\n", r);
|
|
result = 1;
|
|
continue;
|
|
}
|
|
if (e != i)
|
|
{
|
|
printf ("exponent wrong %d (%.20Lg)\n", e, x);
|
|
result = 1;
|
|
continue;
|
|
}
|
|
puts ("ok");
|
|
}
|
|
|
|
for (i = LDBL_MIN_EXP, x = LDBL_MIN; i >= LDBL_MIN_EXP - LDBL_MANT_DIG + 1;
|
|
--i, x /= 2.0L)
|
|
{
|
|
printf ("2^%d: ", i);
|
|
|
|
r = frexpl (x, &e);
|
|
if (r != 0.5L)
|
|
{
|
|
printf ("mantissa incorrect: %.20La\n", r);
|
|
result = 1;
|
|
continue;
|
|
}
|
|
if (e != i)
|
|
{
|
|
printf ("exponent wrong %d (%.20Lg)\n", e, x);
|
|
result = 1;
|
|
continue;
|
|
}
|
|
puts ("ok");
|
|
}
|
|
|
|
}
|
|
# endif
|
|
|
|
#if 0
|
|
{
|
|
int e;
|
|
long double r = frexpl (LDBL_MIN * LDBL_EPSILON, &e);
|
|
|
|
if (r != 0.5)
|
|
{
|
|
printf ("frexpl (LDBL_MIN * LDBL_EPSILON, ...): mantissa wrong: %Lg\n",
|
|
r);
|
|
result = 1;
|
|
}
|
|
else if (e != -16444)
|
|
{
|
|
printf ("frexpl (LDBL_MIN * LDBL_EPSILON, ...): exponent wrong: %d\n",
|
|
e);
|
|
result = 1;
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
{
|
|
double x = 0x100000001ll + (double) 0.5;
|
|
double q;
|
|
double r;
|
|
|
|
r = modf (x, &q);
|
|
if (q != (double) 0x100000001ll || r != 0.5)
|
|
{
|
|
printf ("modf (%g, ...) failed\n", x);
|
|
result = 1;
|
|
}
|
|
}
|
|
|
|
{
|
|
union ieee754_float v1;
|
|
union ieee754_float v2;
|
|
float f;
|
|
|
|
v1.f = f = FLT_MIN;
|
|
if (fpclassify (f) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (FLT_MIN) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
f = nextafterf (f, FLT_MIN / 2.0f);
|
|
if (fpclassify (f) != FP_SUBNORMAL)
|
|
{
|
|
printf ("fpclassify (FLT_MIN-epsilon) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
v2.f = f = nextafterf (f, FLT_MIN);
|
|
if (fpclassify (f) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (FLT_MIN-epsilon+epsilon) failed: %d\n",
|
|
fpclassify (f));
|
|
result = 1;
|
|
}
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("FLT_MIN: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("FLT_MIN: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("FLT_MIN: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = -FLT_MIN;
|
|
if (fpclassify (f) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-FLT_MIN) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
f = nextafterf (f, -FLT_MIN / 2.0f);
|
|
if (fpclassify (f) != FP_SUBNORMAL)
|
|
{
|
|
printf ("fpclassify (-FLT_MIN-epsilon) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
v2.f = f = nextafterf (f, -FLT_MIN);
|
|
if (fpclassify (f) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-FLT_MIN-epsilon+epsilon) failed: %d\n",
|
|
fpclassify (f));
|
|
result = 1;
|
|
}
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("-FLT_MIN: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-FLT_MIN: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-FLT_MIN: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
f = FLT_MAX;
|
|
if (fpclassify (f) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (FLT_MAX) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
f = nextafterf (f, INFINITY);
|
|
if (fpclassify (f) != FP_INFINITE)
|
|
{
|
|
printf ("fpclassify (FLT_MAX+epsilon) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
|
|
f = -FLT_MAX;
|
|
if (fpclassify (f) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-FLT_MAX) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
f = nextafterf (f, -INFINITY);
|
|
if (fpclassify (f) != FP_INFINITE)
|
|
{
|
|
printf ("fpclassify (-FLT_MAX-epsilon) failed: %d\n", fpclassify (f));
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = 0.0625;
|
|
f = nextafterf (f, 0.0);
|
|
v2.f = f = nextafterf (f, 1.0);
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("0.0625f down: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0625f down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("0.0625f down: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = 0.0625;
|
|
f = nextafterf (f, 1.0);
|
|
v2.f = f = nextafterf (f, 0.0);
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("0.0625f up: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0625f up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("0.0625f up: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = -0.0625;
|
|
f = nextafterf (f, 0.0);
|
|
v2.f = f = nextafterf (f, -1.0);
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("-0.0625f up: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-0.0625f up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-0.0625f up: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = -0.0625;
|
|
f = nextafterf (f, -1.0);
|
|
v2.f = f = nextafterf (f, 0.0);
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("-0.0625f down: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-0.0625f down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-0.0625f down: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = 0.0f;
|
|
f = nextafterf (f, 1.0);
|
|
v2.f = nextafterf (f, -1.0);
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("0.0f up: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0f up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (0 != v2.ieee.negative)
|
|
{
|
|
printf ("0.0f up: negative differs: 0 vs %d\n",
|
|
v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.f = f = 0.0f;
|
|
f = nextafterf (f, -1.0);
|
|
v2.f = nextafterf (f, 1.0);
|
|
|
|
if (v1.ieee.mantissa != v2.ieee.mantissa)
|
|
{
|
|
printf ("0.0f down: mantissa differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa, v2.ieee.mantissa);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0f down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (1 != v2.ieee.negative)
|
|
{
|
|
printf ("0.0f down: negative differs: 1 vs %d\n",
|
|
v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
if (nextafterf (0.0f, INFINITY) != nextafterf (0.0f, 1.0f)
|
|
|| nextafterf (-0.0f, INFINITY) != nextafterf (-0.0f, 1.0f)
|
|
|| nextafterf (0.0f, -INFINITY) != nextafterf (0.0f, -1.0f)
|
|
|| nextafterf (-0.0f, -INFINITY) != nextafterf (-0.0f, -1.0f))
|
|
{
|
|
printf ("nextafterf (+-0, +-Inf) != nextafterf (+-0, +-1)\n");
|
|
result = 1;
|
|
}
|
|
|
|
if (nexttowardf (0.0f, INFINITY) != nexttowardf (0.0f, 1.0f)
|
|
|| nexttowardf (-0.0f, INFINITY) != nexttowardf (-0.0f, 1.0f)
|
|
|| nexttowardf (0.0f, -INFINITY) != nexttowardf (0.0f, -1.0f)
|
|
|| nexttowardf (-0.0f, -INFINITY) != nexttowardf (-0.0f, -1.0f))
|
|
{
|
|
printf ("nexttowardf (+-0, +-Inf) != nexttowardf (+-0, +-1)\n");
|
|
result = 1;
|
|
}
|
|
}
|
|
|
|
{
|
|
union ieee754_double v1;
|
|
union ieee754_double v2;
|
|
double d;
|
|
|
|
v1.d = d = DBL_MIN;
|
|
if (fpclassify (d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (DBL_MIN) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
d = nextafter (d, DBL_MIN / 2.0);
|
|
if (fpclassify (d) != FP_SUBNORMAL)
|
|
{
|
|
printf ("fpclassify (DBL_MIN-epsilon) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
v2.d = d = nextafter (d, DBL_MIN);
|
|
if (fpclassify (d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (DBL_MIN-epsilon+epsilon) failed: %d\n",
|
|
fpclassify (d));
|
|
result = 1;
|
|
}
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("DBL_MIN: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("DBL_MIN: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("DBL_MIN: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("DBL_MIN: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = -DBL_MIN;
|
|
if (fpclassify (d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-DBL_MIN) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
d = nextafter (d, -DBL_MIN / 2.0);
|
|
if (fpclassify (d) != FP_SUBNORMAL)
|
|
{
|
|
printf ("fpclassify (-DBL_MIN-epsilon) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
v2.d = d = nextafter (d, -DBL_MIN);
|
|
if (fpclassify (d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-DBL_MIN-epsilon+epsilon) failed: %d\n",
|
|
fpclassify (d));
|
|
result = 1;
|
|
}
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("-DBL_MIN: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("-DBL_MIN: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-DBL_MIN: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-DBL_MIN: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
d = DBL_MAX;
|
|
if (fpclassify (d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (DBL_MAX) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
d = nextafter (d, INFINITY);
|
|
if (fpclassify (d) != FP_INFINITE)
|
|
{
|
|
printf ("fpclassify (DBL_MAX+epsilon) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
|
|
d = -DBL_MAX;
|
|
if (fpclassify (d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-DBL_MAX) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
d = nextafter (d, -INFINITY);
|
|
if (fpclassify (d) != FP_INFINITE)
|
|
{
|
|
printf ("fpclassify (-DBL_MAX-epsilon) failed: %d\n", fpclassify (d));
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = 0.0625;
|
|
d = nextafter (d, 0.0);
|
|
v2.d = d = nextafter (d, 1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0625 down: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0625 down: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0625 down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("0.0625 down: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = 0.0625;
|
|
d = nextafter (d, 1.0);
|
|
v2.d = d = nextafter (d, 0.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0625 up: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0625 up: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0625 up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("0.0625 up: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = -0.0625;
|
|
d = nextafter (d, 0.0);
|
|
v2.d = d = nextafter (d, -1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("-0.0625 up: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("-0.0625 up: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-0.0625 up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-0.0625 up: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = -0.0625;
|
|
d = nextafter (d, -1.0);
|
|
v2.d = d = nextafter (d, 0.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("-0.0625 down: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("-0.0625 down: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-0.0625 down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-0.0625 down: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = 0.0;
|
|
d = nextafter (d, 1.0);
|
|
v2.d = nextafter (d, -1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0 up: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0 up: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0 up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (0 != v2.ieee.negative)
|
|
{
|
|
printf ("0.0 up: negative differs: 0 vs %d\n",
|
|
v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = d = 0.0;
|
|
d = nextafter (d, -1.0);
|
|
v2.d = nextafter (d, 1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0 down: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0 down: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0 down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (1 != v2.ieee.negative)
|
|
{
|
|
printf ("0.0 down: negative differs: 1 vs %d\n",
|
|
v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
if (nextafter (0.0, INFINITY) != nextafter (0.0, 1.0)
|
|
|| nextafter (-0.0, INFINITY) != nextafter (-0.0, 1.0)
|
|
|| nextafter (0.0, -INFINITY) != nextafter (0.0, -1.0)
|
|
|| nextafter (-0.0, -INFINITY) != nextafter (-0.0, -1.0))
|
|
{
|
|
printf ("nextafter (+-0, +-Inf) != nextafter (+-0, +-1)\n");
|
|
result = 1;
|
|
}
|
|
|
|
if (nexttoward (0.0, INFINITY) != nexttoward (0.0, 1.0)
|
|
|| nexttoward (-0.0, INFINITY) != nexttoward (-0.0, 1.0)
|
|
|| nexttoward (0.0, -INFINITY) != nexttoward (0.0, -1.0)
|
|
|| nexttoward (-0.0, -INFINITY) != nexttoward (-0.0, -1.0))
|
|
{
|
|
printf ("nexttoward (+-0, +-Inf) != nexttoward (+-0, +-1)\n");
|
|
result = 1;
|
|
}
|
|
}
|
|
|
|
#ifndef NO_LONG_DOUBLE
|
|
{
|
|
union ieee854_long_double v1;
|
|
union ieee854_long_double v2;
|
|
long double ld;
|
|
|
|
v1.d = ld = LDBL_MIN;
|
|
if (fpclassify (ld) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (LDBL_MIN) failed: %d\n", fpclassify (ld));
|
|
result = 1;
|
|
}
|
|
ld = nextafterl (ld, LDBL_MIN / 2.0);
|
|
if (fpclassify (ld) != FP_SUBNORMAL)
|
|
{
|
|
printf ("fpclassify (LDBL_MIN-epsilon) failed: %d (%La)\n",
|
|
fpclassify (ld), ld);
|
|
result = 1;
|
|
}
|
|
v2.d = ld = nextafterl (ld, LDBL_MIN);
|
|
if (fpclassify (ld) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n",
|
|
fpclassify (ld), ld);
|
|
result = 1;
|
|
}
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("LDBL_MIN: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("LDBL_MIN: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("LDBL_MIN: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("LDBL_MIN: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = -LDBL_MIN;
|
|
if (fpclassify (ld) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-LDBL_MIN) failed: %d\n", fpclassify (ld));
|
|
result = 1;
|
|
}
|
|
ld = nextafterl (ld, -LDBL_MIN / 2.0);
|
|
if (fpclassify (ld) != FP_SUBNORMAL)
|
|
{
|
|
printf ("fpclassify (-LDBL_MIN-epsilon) failed: %d (%La)\n",
|
|
fpclassify (ld), ld);
|
|
result = 1;
|
|
}
|
|
v2.d = ld = nextafterl (ld, -LDBL_MIN);
|
|
if (fpclassify (ld) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n",
|
|
fpclassify (ld), ld);
|
|
result = 1;
|
|
}
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("-LDBL_MIN: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("-LDBL_MIN: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-LDBL_MIN: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-LDBL_MIN: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
ld = LDBL_MAX;
|
|
if (fpclassify (ld) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (LDBL_MAX) failed: %d\n", fpclassify (ld));
|
|
result = 1;
|
|
}
|
|
ld = nextafterl (ld, INFINITY);
|
|
if (fpclassify (ld) != FP_INFINITE)
|
|
{
|
|
printf ("fpclassify (LDBL_MAX+epsilon) failed: %d\n", fpclassify (ld));
|
|
result = 1;
|
|
}
|
|
|
|
ld = -LDBL_MAX;
|
|
if (fpclassify (ld) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (-LDBL_MAX) failed: %d\n", fpclassify (ld));
|
|
result = 1;
|
|
}
|
|
ld = nextafterl (ld, -INFINITY);
|
|
if (fpclassify (ld) != FP_INFINITE)
|
|
{
|
|
printf ("fpclassify (-LDBL_MAX-epsilon) failed: %d\n",
|
|
fpclassify (ld));
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = 0.0625;
|
|
ld = nextafterl (ld, 0.0);
|
|
v2.d = ld = nextafterl (ld, 1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0625L down: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0625L down: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0625L down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("0.0625L down: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = 0.0625;
|
|
ld = nextafterl (ld, 1.0);
|
|
v2.d = ld = nextafterl (ld, 0.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0625L up: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0625L up: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0625L up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("0.0625L up: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = -0.0625;
|
|
ld = nextafterl (ld, 0.0);
|
|
v2.d = ld = nextafterl (ld, -1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("-0.0625L up: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("-0.0625L up: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-0.0625L up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-0.0625L up: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = -0.0625;
|
|
ld = nextafterl (ld, -1.0);
|
|
v2.d = ld = nextafterl (ld, 0.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("-0.0625L down: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("-0.0625L down: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("-0.0625L down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.negative != v2.ieee.negative)
|
|
{
|
|
printf ("-0.0625L down: negative differs: %d vs %d\n",
|
|
v1.ieee.negative, v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = 0.0;
|
|
ld = nextafterl (ld, 1.0);
|
|
v2.d = nextafterl (ld, -1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0L up: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0L up: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0L up: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (0 != v2.ieee.negative)
|
|
{
|
|
printf ("0.0L up: negative differs: 0 vs %d\n",
|
|
v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
v1.d = ld = 0.0;
|
|
ld = nextafterl (ld, -1.0);
|
|
v2.d = nextafterl (ld, 1.0);
|
|
|
|
if (v1.ieee.mantissa0 != v2.ieee.mantissa0)
|
|
{
|
|
printf ("0.0L down: mantissa0 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa0, v2.ieee.mantissa0);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
|
|
{
|
|
printf ("0.0L down: mantissa1 differs: %8x vs %8x\n",
|
|
v1.ieee.mantissa1, v2.ieee.mantissa1);
|
|
result = 1;
|
|
}
|
|
if (v1.ieee.exponent != v2.ieee.exponent)
|
|
{
|
|
printf ("0.0L down: exponent differs: %4x vs %4x\n",
|
|
v1.ieee.exponent, v2.ieee.exponent);
|
|
result = 1;
|
|
}
|
|
if (1 != v2.ieee.negative)
|
|
{
|
|
printf ("0.0L down: negative differs: 1 vs %d\n",
|
|
v2.ieee.negative);
|
|
result = 1;
|
|
}
|
|
|
|
if (nextafterl (0.0, INFINITY) != nextafterl (0.0, 1.0)
|
|
|| nextafterl (-0.0, INFINITY) != nextafterl (-0.0, 1.0)
|
|
|| nextafterl (0.0, -INFINITY) != nextafterl (0.0, -1.0)
|
|
|| nextafterl (-0.0, -INFINITY) != nextafterl (-0.0, -1.0))
|
|
{
|
|
printf ("nextafterl (+-0, +-Inf) != nextafterl (+-0, +-1)\n");
|
|
result = 1;
|
|
}
|
|
|
|
if (nexttowardl (0.0L, INFINITY) != nexttowardl (0.0L, 1.0L)
|
|
|| nexttowardl (-0.0L, INFINITY) != nexttowardl (-0.0L, 1.0L)
|
|
|| nexttowardl (0.0L, -INFINITY) != nexttowardl (0.0L, -1.0L)
|
|
|| nexttowardl (-0.0L, -INFINITY) != nexttowardl (-0.0L, -1.0L))
|
|
{
|
|
printf ("nexttowardl (+-0, +-Inf) != nexttowardl (+-0, +-1)\n");
|
|
result = 1;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
if (! isnormal (FLT_MIN))
|
|
{
|
|
puts ("isnormal (FLT_MIN) failed");
|
|
result = 1;
|
|
}
|
|
if (! isnormal (DBL_MIN))
|
|
{
|
|
puts ("isnormal (DBL_MIN) failed");
|
|
result = 1;
|
|
}
|
|
#ifndef NO_LONG_DOUBLE
|
|
if (! isnormal (LDBL_MIN))
|
|
{
|
|
puts ("isnormal (LDBL_MIN) failed");
|
|
result = 1;
|
|
}
|
|
#endif
|
|
|
|
#ifdef __i386__
|
|
/* This is a test for the strange long doubles in x86 FPUs. */
|
|
{
|
|
union
|
|
{
|
|
char b[10];
|
|
long double d;
|
|
} u =
|
|
{ .b = { 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0 } };
|
|
|
|
if (fpclassify (u.d) != FP_NORMAL)
|
|
{
|
|
printf ("fpclassify (0x00008000000000000000) failed: %d (%Lg)\n",
|
|
fpclassify (u.d), u.d);
|
|
result = 1;
|
|
}
|
|
}
|
|
|
|
/* Special NaNs in x86 long double. Test for scalbl. */
|
|
{
|
|
union
|
|
{
|
|
char b[10];
|
|
long double d;
|
|
} u =
|
|
{ .b = { 0, 1, 0, 0, 0, 0, 0, 0xc0, 0xff, 0x7f } };
|
|
long double r;
|
|
|
|
r = scalbl (u.d, 0.0);
|
|
if (!isnan (r))
|
|
{
|
|
puts ("scalbl(NaN, 0) does not return NaN");
|
|
result = 1;
|
|
}
|
|
else if (memcmp (&r, &u.d, sizeof (double)) != 0)
|
|
{
|
|
puts ("scalbl(NaN, 0) does not return the same NaN");
|
|
result = 1;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifndef NO_LONG_DOUBLE
|
|
{
|
|
long double r;
|
|
|
|
feclearexcept (FE_ALL_EXCEPT);
|
|
r = scalbl (LDBL_MIN, 2147483647);
|
|
if (! isinf (r))
|
|
{
|
|
puts ("scalbl (LDBL_MIN, 2147483647) does not return Inf");
|
|
result = 1;
|
|
}
|
|
else if (signbit (r) != 0)
|
|
{
|
|
puts ("scalbl (LDBL_MIN, 2147483647) returns -Inf");
|
|
result = 1;
|
|
}
|
|
else if (fetestexcept (FE_UNDERFLOW))
|
|
{
|
|
puts ("scalbl(NaN, 0) raises underflow exception");
|
|
result = 1;
|
|
}
|
|
|
|
feclearexcept (FE_ALL_EXCEPT);
|
|
r = scalbl (LDBL_MAX, -2147483647);
|
|
if (r != 0.0)
|
|
{
|
|
puts ("scalbl (LDBL_MAX, -2147483647) does not return 0");
|
|
result = 1;
|
|
}
|
|
else if (signbit (r) != 0)
|
|
{
|
|
puts ("scalbl (LDBL_MAX, -2147483647) returns -Inf");
|
|
result = 1;
|
|
}
|
|
else if (fetestexcept (FE_OVERFLOW))
|
|
{
|
|
puts ("scalbl(NaN, 0) raises overflow exception");
|
|
result = 1;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
return result;
|
|
}
|