mirror of
https://github.com/python/cpython.git
synced 2025-12-08 02:08:20 +00:00
Correct wrong calculation of pow(0.0, 0.0, negative_number)
This commit is contained in:
parent
0693dd232e
commit
86c04c252b
1 changed files with 6 additions and 5 deletions
|
|
@ -367,12 +367,8 @@ float_pow(v, w, z)
|
||||||
iw = ((floatobject *)w)->ob_fval;
|
iw = ((floatobject *)w)->ob_fval;
|
||||||
intw = (long)iw;
|
intw = (long)iw;
|
||||||
if (iw == intw) {
|
if (iw == intw) {
|
||||||
errno = 0;
|
|
||||||
ix = powi(iv, intw);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* Sort out special cases here instead of relying on pow() */
|
/* Sort out special cases here instead of relying on pow() */
|
||||||
if (iw == 0.0) { /* x**0 is 1, even 0**0 */
|
if (intw == 0) { /* x**0 is 1, even 0**0 */
|
||||||
if ((object *)z!=None) {
|
if ((object *)z!=None) {
|
||||||
ix=fmod(1.0, z->ob_fval);
|
ix=fmod(1.0, z->ob_fval);
|
||||||
if (ix!=0 && z->ob_fval<0) ix+=z->ob_fval;
|
if (ix!=0 && z->ob_fval<0) ix+=z->ob_fval;
|
||||||
|
|
@ -380,6 +376,11 @@ float_pow(v, w, z)
|
||||||
else ix=1.0;
|
else ix=1.0;
|
||||||
return newfloatobject(ix);
|
return newfloatobject(ix);
|
||||||
}
|
}
|
||||||
|
errno = 0;
|
||||||
|
ix = powi(iv, intw);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Sort out special cases here instead of relying on pow() */
|
||||||
if (iv == 0.0) {
|
if (iv == 0.0) {
|
||||||
if (iw < 0.0) {
|
if (iw < 0.0) {
|
||||||
err_setstr(ValueError, "0.0 to a negative power");
|
err_setstr(ValueError, "0.0 to a negative power");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue