From efe2c8d032d1ec68f6260add6dd5e61f4a8439fb Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 18 May 1989 18:02:24 +0000 Subject: [PATCH] some more fixes --- lang/cem/libcc/math/asin.c | 18 ++++++++++-------- lang/cem/libcc/math/exp.c | 5 +++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lang/cem/libcc/math/asin.c b/lang/cem/libcc/math/asin.c index 06bc743fb..f8c227e99 100644 --- a/lang/cem/libcc/math/asin.c +++ b/lang/cem/libcc/math/asin.c @@ -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; diff --git a/lang/cem/libcc/math/exp.c b/lang/cem/libcc/math/exp.c index b34347ab8..f3166d590 100644 --- a/lang/cem/libcc/math/exp.c +++ b/lang/cem/libcc/math/exp.c @@ -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; -- 2.34.1