changed pow() a little

This commit is contained in:
eck 1990-08-28 13:59:36 +00:00
parent a41c51783a
commit bc83231874

View file

@ -38,17 +38,15 @@ pow(double x, double y)
x = -x; x = -x;
} }
x = log(x); x = log(x);
if (x < 0) { if (x < 0) {
x = -x; x = -x;
y = -y; 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; errno = ERANGE;
return 0; return result_neg ? -HUGE_VAL : HUGE_VAL;
}
if (y < M_LN_MIN_D/x) {
errno = ERANGE;
return 0;
} }
x = exp(x * y); x = exp(x * y);