зеркало из https://github.com/mozilla/gecko-dev.git
ECMA and C99 specs do not agree on all results for pow(). When using libm for JavaScript math functions, we need to convert libm's differing C99 results to ECMA-compliant results. This change might be all we need to get our libm implementation ECMA compliant, so we can examine moving js math functions over to OS libraries on all platforms. b=320770 r=mento sr=brendan
This commit is contained in:
Родитель
e756ce4c1a
Коммит
9444c564c2
|
@ -283,6 +283,16 @@ math_pow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
return JS_FALSE;
|
||||
if (!js_ValueToNumber(cx, argv[1], &y))
|
||||
return JS_FALSE;
|
||||
#if !JS_USE_FDLIBM_MATH
|
||||
/*
|
||||
* Because C99 and ECMA specify different behavior for pow(),
|
||||
* we need to wrap the libm call to make it ECMA compliant.
|
||||
*/
|
||||
if (!JSDOUBLE_IS_FINITE(y) && (x == 1.0 || x == -1.0)) {
|
||||
*rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif
|
||||
z = fd_pow(x, y);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче