about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/dbl-64')
-rw-r--r--sysdeps/ieee754/dbl-64/s_expm1.c6
-rw-r--r--sysdeps/ieee754/dbl-64/s_sin.c15
-rw-r--r--sysdeps/ieee754/dbl-64/s_tan.c31
3 files changed, 39 insertions, 13 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_expm1.c b/sysdeps/ieee754/dbl-64/s_expm1.c
index bfd15b2e31..324354336e 100644
--- a/sysdeps/ieee754/dbl-64/s_expm1.c
+++ b/sysdeps/ieee754/dbl-64/s_expm1.c
@@ -112,6 +112,7 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
  * to produce the hexadecimal values shown.
  */
 
+#include <errno.h>
 #include "math.h"
 #include "math_private.h"
 #define one Q[0]
@@ -159,7 +160,10 @@ Q[]  =  {1.0, -3.33333333333331316428e-02, /* BFA11111 111110F4 */
 		         return x+x; 	 /* NaN */
 		    else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
 	        }
-	        if(x > o_threshold) return huge*huge; /* overflow */
+	        if(x > o_threshold) {
+		  __set_errno (ERANGE);
+		  return huge*huge; /* overflow */
+		}
 	    }
 	    if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
 		if(x+tiny<0.0)		/* raise inexact */
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 86e1a6d121..b40776f5e2 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -1,7 +1,7 @@
 /*
  * IBM Accurate Mathematical Library
  * written by International Business Machines Corp.
- * Copyright (C) 2001 Free Software Foundation
+ * Copyright (C) 2001, 2009 Free Software Foundation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -48,6 +48,7 @@
 /****************************************************************************/
 
 
+#include <errno.h>
 #include "endian.h"
 #include "mydefs.h"
 #include "usncs.h"
@@ -329,7 +330,11 @@ double __sin(double x){
 	}    /*   else  if (k <  0x7ff00000 )    */
 
 /*--------------------- |x| > 2^1024 ----------------------------------*/
-	else return x / x;
+	else {
+	  if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
+	    __set_errno (EDOM);
+	  return x / x;
+	}
 	return 0;         /* unreachable */
 }
 
@@ -572,7 +577,11 @@ double __cos(double x)
 
 
 
-  else return x / x; /* |x| > 2^1024 */
+  else {
+    if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
+      __set_errno (EDOM);
+    return x / x; /* |x| > 2^1024 */
+  }
   return 0;
 
 }
diff --git a/sysdeps/ieee754/dbl-64/s_tan.c b/sysdeps/ieee754/dbl-64/s_tan.c
index cf8d4d0267..4e26d90ae1 100644
--- a/sysdeps/ieee754/dbl-64/s_tan.c
+++ b/sysdeps/ieee754/dbl-64/s_tan.c
@@ -1,7 +1,7 @@
 /*
  * IBM Accurate Mathematical Library
  * written by International Business Machines Corp.
- * Copyright (C) 2001 Free Software Foundation
+ * Copyright (C) 2001, 2009 Free Software Foundation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -33,6 +33,8 @@
 /* round to nearest mode of IEEE 754 standard.                       */
 /*                                                                   */
 /*********************************************************************/
+
+#include <errno.h>
 #include "endian.h"
 #include "dla.h"
 #include "mpa.h"
@@ -61,7 +63,11 @@ double tan(double x) {
 
   /* x=+-INF, x=NaN */
   num.d = x;  ux = num.i[HIGH_HALF];
-  if ((ux&0x7ff00000)==0x7ff00000) return x-x;
+  if ((ux&0x7ff00000)==0x7ff00000) {
+    if ((ux&0x7fffffff)==0x7ff00000)
+      __set_errno (EDOM);
+    return x-x;
+  }
 
   w=(x<ZERO) ? -x : x;
 
@@ -108,7 +114,8 @@ double tan(double x) {
     fi = xfg[i][1].d;   gi = xfg[i][2].d;   t2 = pz*(gi+fi)/(gi-pz);
     if ((y=fi+(t2-fi*u3.d))==fi+(t2+fi*u3.d))  return (s*y);
     t3 = (t2<ZERO) ? -t2 : t2;
-    if ((y=fi+(t2-(t4=fi*ua3.d+t3*ub3.d)))==fi+(t2+t4))  return (s*y);
+    t4 = fi*ua3.d+t3*ub3.d;
+    if ((y=fi+(t2-t4))==fi+(t2+t4))  return (s*y);
 
     /* Second stage */
     ffi = xfg[i][3].d;
@@ -216,13 +223,15 @@ double tan(double x) {
       t2 = pz*(fi+gi)/(fi+pz);
       if ((y=gi-(t2-gi*u10.d))==gi-(t2+gi*u10.d))  return (-sy*y);
       t3 = (t2<ZERO) ? -t2 : t2;
-      if ((y=gi-(t2-(t4=gi*ua10.d+t3*ub10.d)))==gi-(t2+t4))  return (-sy*y); }
+      t4 = gi*ua10.d+t3*ub10.d;
+      if ((y=gi-(t2-t4))==gi-(t2+t4))  return (-sy*y); }
     else   {
       /* tan */
       t2 = pz*(gi+fi)/(gi-pz);
       if ((y=fi+(t2-fi*u9.d))==fi+(t2+fi*u9.d))  return (sy*y);
       t3 = (t2<ZERO) ? -t2 : t2;
-      if ((y=fi+(t2-(t4=fi*ua9.d+t3*ub9.d)))==fi+(t2+t4))  return (sy*y); }
+      t4 = fi*ua9.d+t3*ub9.d;
+      if ((y=fi+(t2-t4))==fi+(t2+t4))  return (sy*y); }
 
     /* Second stage */
     ffi = xfg[i][3].d;
@@ -327,13 +336,15 @@ double tan(double x) {
       t2 = pz*(fi+gi)/(fi+pz);
       if ((y=gi-(t2-gi*u18.d))==gi-(t2+gi*u18.d))  return (-sy*y);
       t3 = (t2<ZERO) ? -t2 : t2;
-      if ((y=gi-(t2-(t4=gi*ua18.d+t3*ub18.d)))==gi-(t2+t4))  return (-sy*y); }
+      t4 = gi*ua18.d+t3*ub18.d;
+      if ((y=gi-(t2-t4))==gi-(t2+t4))  return (-sy*y); }
     else   {
       /* tan */
       t2 = pz*(gi+fi)/(gi-pz);
       if ((y=fi+(t2-fi*u17.d))==fi+(t2+fi*u17.d))  return (sy*y);
       t3 = (t2<ZERO) ? -t2 : t2;
-      if ((y=fi+(t2-(t4=fi*ua17.d+t3*ub17.d)))==fi+(t2+t4))  return (sy*y); }
+      t4 = fi*ua17.d+t3*ub17.d;
+      if ((y=fi+(t2-t4))==fi+(t2+t4))  return (sy*y); }
 
     /* Second stage */
     ffi = xfg[i][3].d;
@@ -431,13 +442,15 @@ double tan(double x) {
     t2 = pz*(fi+gi)/(fi+pz);
     if ((y=gi-(t2-gi*u26.d))==gi-(t2+gi*u26.d))  return (-sy*y);
     t3 = (t2<ZERO) ? -t2 : t2;
-    if ((y=gi-(t2-(t4=gi*ua26.d+t3*ub26.d)))==gi-(t2+t4))  return (-sy*y); }
+    t4 = gi*ua26.d+t3*ub26.d;
+    if ((y=gi-(t2-t4))==gi-(t2+t4))  return (-sy*y); }
   else   {
     /* tan */
     t2 = pz*(gi+fi)/(gi-pz);
     if ((y=fi+(t2-fi*u25.d))==fi+(t2+fi*u25.d))  return (sy*y);
     t3 = (t2<ZERO) ? -t2 : t2;
-    if ((y=fi+(t2-(t4=fi*ua25.d+t3*ub25.d)))==fi+(t2+t4))  return (sy*y); }
+    t4 = fi*ua25.d+t3*ub25.d;
+    if ((y=fi+(t2-t4))==fi+(t2+t4))  return (sy*y); }
 
   /* Second stage */
   ffi = xfg[i][3].d;