Bug 775680 - Math.pow should use powi if the exponent is an integer-valued double. r=dvander

This commit is contained in:
Jan de Mooij 2012-07-19 20:43:32 +02:00
parent 60351e8369
commit ba908b4d16

View File

@ -475,8 +475,13 @@ js_math_pow(JSContext *cx, unsigned argc, Value *vp)
return JS_TRUE;
}
if (vp[3].isInt32())
z = powi(x, vp[3].toInt32());
/*
* Use powi if the exponent is an integer or an integer-valued double.
* We don't have to check for NaN since a comparison with NaN is always
* false.
*/
if (int32_t(y) == y)
z = powi(x, int32_t(y));
else
z = pow(x, y);