From bc83231874a683e1303cb555409baffe0f815f4d Mon Sep 17 00:00:00 2001 From: eck Date: Tue, 28 Aug 1990 13:59:36 +0000 Subject: [PATCH] changed pow() a little --- lang/cem/libcc.ansi/math/pow.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lang/cem/libcc.ansi/math/pow.c b/lang/cem/libcc.ansi/math/pow.c index b9b7106b5..b4a9006e3 100644 --- a/lang/cem/libcc.ansi/math/pow.c +++ b/lang/cem/libcc.ansi/math/pow.c @@ -38,17 +38,15 @@ pow(double x, double y) x = -x; } x = log(x); + if (x < 0) { x = -x; y = -y; } - if (y > M_LN_MAX_D/x) { + /* Beware of overflow in the multiplication */ + if (x > 1.0 && y > DBL_MAX/x) { errno = ERANGE; - return 0; - } - if (y < M_LN_MIN_D/x) { - errno = ERANGE; - return 0; + return result_neg ? -HUGE_VAL : HUGE_VAL; } x = exp(x * y); -- 2.34.1