Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 3984:0613f17dcfd8 legacy-trunk
Correct wrong calculation of pow(0.0, 0.0, negative_number)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 09 Aug 1996 20:50:14 +0000 |
| parents | 17030515f623 |
| children | 1a0aa986f6fa |
line wrap: on
line diff
--- a/Objects/floatobject.c Fri Aug 09 20:48:52 1996 +0000 +++ b/Objects/floatobject.c Fri Aug 09 20:50:14 1996 +0000 @@ -367,12 +367,8 @@ iw = ((floatobject *)w)->ob_fval; intw = (long)iw; if (iw == intw) { - errno = 0; - ix = powi(iv, intw); - } - else { /* 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) { ix=fmod(1.0, z->ob_fval); if (ix!=0 && z->ob_fval<0) ix+=z->ob_fval; @@ -380,6 +376,11 @@ else ix=1.0; 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 (iw < 0.0) { err_setstr(ValueError, "0.0 to a negative power");
