2003-12-06  Ulrich Drepper  <drepper@redhat.com>

	* math/Makefile (tests): Add bug-nextafter.
	* math/bug-nextafter.c: New file.
	* sysdeps/generic/s_nextafter.c: Construct overflow value correctly.
	* sysdeps/ieee754/flt-32/s_nextafterf.c: Likewise.
	* math/libm-test.inc (nextafter_test): Add test for overflow after
	+/-FLT_MAX etc.
This commit is contained in:
Ulrich Drepper 2003-12-07 03:25:24 +00:00
parent 57d20ee7f2
commit 64b02fd2f5
6 changed files with 62 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2003-12-06 Ulrich Drepper <drepper@redhat.com>
* math/Makefile (tests): Add bug-nextafter.
* math/bug-nextafter.c: New file.
* sysdeps/generic/s_nextafter.c: Construct overflow value correctly.
* sysdeps/ieee754/flt-32/s_nextafterf.c: Likewise.
* math/libm-test.inc (nextafter_test): Add test for overflow after
+/-FLT_MAX etc.
2003-12-04 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/fpu/fgetexcptflg.c (__fegetexceptflag): Add masking

View File

@ -87,7 +87,8 @@ distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
# Rules for the test suite.
tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret
test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
bug-nextafter
# We do the `long double' tests only if this data type is available and
# distinct from `double'.
test-longdouble-yes = test-ldouble test-ildoubl

28
math/bug-nextafter.c Normal file
View File

@ -0,0 +1,28 @@
#include <math.h>
#include <float.h>
#include <stdlib.h>
#include <stdio.h>
int
main (void)
{
int result = 0;
float i = INFINITY;
float m = FLT_MAX;
if (nextafterf (m, i) != i)
{
puts ("nextafterf failed");
++result;
}
double di = INFINITY;
double dm = DBL_MAX;
if (nextafter (dm, di) != di)
{
puts ("nextafter failed");
++result;
}
return result;
}

View File

@ -3437,6 +3437,11 @@ nextafter_test (void)
TEST_ff_f (nextafter, 1.1L, nan_value, nan_value);
TEST_ff_f (nextafter, nan_value, nan_value, nan_value);
FLOAT fltmax = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX,
LDBL_MAX, DBL_MAX, FLT_MAX);
TEST_ff_f (nextafter, fltmax, plus_infty, plus_infty);
TEST_ff_f (nextafter, -fltmax, minus_infty, minus_infty);
#ifdef TEST_LDOUBLE
// XXX Enable once gcc is fixed.
//TEST_ff_f (nextafter, 0x0.00000040000000000000p-16385L, -0.1L, 0x0.0000003ffffffff00000p-16385L);

View File

@ -27,6 +27,7 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
#include "math.h"
#include "math_private.h"
#include <float.h>
#ifdef __STDC__
double __nextafter(double x, double y)
@ -70,7 +71,14 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
}
}
hy = hx&0x7ff00000;
if(hy>=0x7ff00000) return x+x; /* overflow */
if(hy>=0x7ff00000) {
#if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
return x+x; /* overflow */
#else
/* Note that y is either +Inf or -Inf. */
return x+y;
#endif
}
if(hy<0x00100000) { /* underflow */
y = x*x;
if(y!=x) { /* raise underflow flag */

View File

@ -19,6 +19,7 @@ static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp
#include "math.h"
#include "math_private.h"
#include <float.h>
#ifdef __STDC__
float __nextafterf(float x, float y)
@ -57,7 +58,14 @@ static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp
}
}
hy = hx&0x7f800000;
if(hy>=0x7f800000) return x+x; /* overflow */
if(hy>=0x7f800000) {
#if FLT_EVAL_METHOD == 0
return x+x; /* overflow */
#else
/* Note that y is either +Inf or -Inf. */
return x+y;
#endif
}
if(hy<0x00800000) { /* underflow */
y = x*x;
if(y!=x) { /* raise underflow flag */