some more fixes
authorceriel <none@none>
Thu, 18 May 1989 18:02:24 +0000 (18:02 +0000)
committerceriel <none@none>
Thu, 18 May 1989 18:02:24 +0000 (18:02 +0000)
lang/cem/libcc/math/asin.c
lang/cem/libcc/math/exp.c

index 06bc743..f8c227e 100644 (file)
@@ -40,7 +40,7 @@ asin_acos(x, cosfl)
                x = -x;
        }
        if (x > 0.5) {
-               i = 1 - cosfl;
+               i = 1;
                if (x > 1) {
                        errno = EDOM;
                        return 0;
@@ -51,16 +51,18 @@ asin_acos(x, cosfl)
        }
        else {
                /* ??? avoid underflow ??? */
+               i = 0;
                g = x * x;
        }
        x += x * g * POLYNOM4(g, p) / POLYNOM5(g, q);
-       if (i == 1) {
-               if (cosfl == 0 || ! negative) {
-                       x = (x + M_PI_4) + M_PI_4;
-               }
-               else if (cosfl && negative) {
-                       x = (x + M_PI_2) + M_PI_2;
-               }
+       if (cosfl) {
+               if (! negative) x = -x;
+       }
+       if ((cosfl == 0) == (i == 1)) {
+               x = (x + M_PI_4) + M_PI_4;
+       }
+       else if (cosfl && negative && i == 1) {
+               x = (x + M_PI_2) + M_PI_2;
        }
        if (! cosfl && negative) x = -x;
        return x;
index b34347a..f3166d5 100644 (file)
@@ -46,6 +46,7 @@ exp(x)
                if (x > M_LN_MAX_D) errno = ERANGE;
                return M_MAX_D;
        }
+       if (negative) x = -x;
 
        /* ??? avoid underflow ??? */
 
@@ -57,6 +58,10 @@ exp(x)
 
                g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4);
        }
+       if (negative) {
+               g = -g;
+               n = -n;
+       }
        xn = g * g;
        x = g * POLYNOM2(xn, p);
        n += 1;