From: eck Date: Tue, 28 Aug 1990 13:59:36 +0000 (+0000) Subject: changed pow() a little X-Git-Tag: release-5-5~1582 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=bc83231874a683e1303cb555409baffe0f815f4d;p=ack.git changed pow() a little --- 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);