summaryrefslogtreecommitdiffstats
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-09 20:50:14 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-09 20:50:14 (GMT)
commit86c04c252b9ec1cb682d9fd52bdd48b61434c4b3 (patch)
tree6cb9a94fe8645637a8ae37a47f7b0d521923c15c /Objects/floatobject.c
parent0693dd232ed861f5aacc2d97695c50bc6cdad3bc (diff)
downloadcpython-86c04c252b9ec1cb682d9fd52bdd48b61434c4b3.zip
cpython-86c04c252b9ec1cb682d9fd52bdd48b61434c4b3.tar.gz
cpython-86c04c252b9ec1cb682d9fd52bdd48b61434c4b3.tar.bz2
Correct wrong calculation of pow(0.0, 0.0, negative_number)
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 0a6aa48..74ef26e 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -367,12 +367,8 @@ float_pow(v, w, z)
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 @@ float_pow(v, w, z)
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");