summary refs log tree commit diff
path: root/sysdeps/libm-ieee754
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754')
-rw-r--r--sysdeps/libm-ieee754/e_scalb.c6
-rw-r--r--sysdeps/libm-ieee754/e_scalbf.c6
-rw-r--r--sysdeps/libm-ieee754/e_scalbl.c6
3 files changed, 15 insertions, 3 deletions
diff --git a/sysdeps/libm-ieee754/e_scalb.c b/sysdeps/libm-ieee754/e_scalb.c
index 86d10bf683..d9a326b2b2 100644
--- a/sysdeps/libm-ieee754/e_scalb.c
+++ b/sysdeps/libm-ieee754/e_scalb.c
@@ -45,9 +45,13 @@ static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $";
 	if (__isnan(x)||__isnan(fn)) return x*fn;
 	if (!__finite(fn)) {
 	    if(fn>0.0) return x*fn;
+	    else if (x == 0)
+	      return x;
+	    else if (!__finite (x))
+	      return __nan ("");
 	    else       return x/(-fn);
 	}
-	if (__rint(fn)!=fn) return (fn-fn)/(fn-fn);
+	if (__rint(fn)!=fn) return __nan ("");
 	if ( fn > 65000.0) return __scalbn(x, 65000);
 	if (-fn > 65000.0) return __scalbn(x,-65000);
 	return __scalbn(x,(int)fn);
diff --git a/sysdeps/libm-ieee754/e_scalbf.c b/sysdeps/libm-ieee754/e_scalbf.c
index 67abbb410e..f51057e7b4 100644
--- a/sysdeps/libm-ieee754/e_scalbf.c
+++ b/sysdeps/libm-ieee754/e_scalbf.c
@@ -42,9 +42,13 @@ static char rcsid[] = "$NetBSD: e_scalbf.c,v 1.3 1995/05/10 20:46:12 jtc Exp $";
 	if (__isnanf(x)||__isnanf(fn)) return x*fn;
 	if (!__finitef(fn)) {
 	    if(fn>(float)0.0) return x*fn;
+	    else if (x == 0)
+	      return x;
+	    else if (!__finitef (x))
+	      return __nanf ("");
 	    else       return x/(-fn);
 	}
-	if (__rintf(fn)!=fn) return (fn-fn)/(fn-fn);
+	if (__rintf(fn)!=fn) return __nanf ("");
 	if ( fn > (float)65000.0) return __scalbnf(x, 65000);
 	if (-fn > (float)65000.0) return __scalbnf(x,-65000);
 	return __scalbnf(x,(int)fn);
diff --git a/sysdeps/libm-ieee754/e_scalbl.c b/sysdeps/libm-ieee754/e_scalbl.c
index 823eebda91..dccc876c85 100644
--- a/sysdeps/libm-ieee754/e_scalbl.c
+++ b/sysdeps/libm-ieee754/e_scalbl.c
@@ -49,9 +49,13 @@ static char rcsid[] = "$NetBSD: $";
 	if (__isnanl(x)||__isnanl(fn)) return x*fn;
 	if (!__finitel(fn)) {
 	    if(fn>0.0) return x*fn;
+	    else if (x == 0)
+	      return x;
+	    else if (!__finitel (x))
+	      return __nanl ("");
 	    else       return x/(-fn);
 	}
-	if (__rintl(fn)!=fn) return (fn-fn)/(fn-fn);
+	if (__rintl(fn)!=fn) return __nanl ("");
 	if ( fn > 65000.0) return __scalbnl(x, 65000);
 	if (-fn > 65000.0) return __scalbnl(x,-65000);
 	return __scalbnl(x,(int)fn);