about summary refs log tree commit diff
path: root/sysdeps/generic/s_nextafter.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/s_nextafter.c')
-rw-r--r--sysdeps/generic/s_nextafter.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sysdeps/generic/s_nextafter.c b/sysdeps/generic/s_nextafter.c
index a016ab0a4d..9290fc6568 100644
--- a/sysdeps/generic/s_nextafter.c
+++ b/sysdeps/generic/s_nextafter.c
@@ -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 */