changed pow() a little
This commit is contained in:
parent
a41c51783a
commit
bc83231874
1 changed files with 4 additions and 6 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue