Backout b85379036da2 because of test failures

This commit is contained in:
Tom Schuster 2011-12-25 15:47:27 +01:00
Родитель fa959181c8
Коммит d100b20fcf
3 изменённых файлов: 18 добавлений и 26 удалений

Просмотреть файл

@ -1,7 +0,0 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
assertEq(Math.round(9007199254740991), 9007199254740991);
assertEq(Math.round(-19007199254740990), -19007199254740990);

Просмотреть файл

@ -577,30 +577,26 @@ js_copysign(double x, double y)
}
#endif
jsdouble
js_math_round_impl(jsdouble x)
{
return js_copysign(floor(x + 0.5), x);
}
JSBool
js_math_round(JSContext *cx, uintN argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
jsdouble x, z;
if (args.length() == 0) {
args.rval().setDouble(js_NaN);
return true;
if (argc == 0) {
vp->setDouble(js_NaN);
return JS_TRUE;
}
double x;
if (!ToNumber(cx, args[0], &x))
return false;
jsdpun u;
u.d = x;
/* Some numbers are so big that adding 0.5 would give the wrong number */
if ((u.s.hi & JSDOUBLE_HI32_EXPMASK) > 52) {
args.rval().setNumber(x);
return true;
}
args.rval().setNumber(js_copysign(floor(x + 0.5), x));
return true;
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
z = js_copysign(floor(x + 0.5), x);
vp->setNumber(z);
return JS_TRUE;
}
static JSBool

Просмотреть файл

@ -121,4 +121,7 @@ js_math_ceil_impl(jsdouble x);
extern jsdouble
js_math_floor_impl(jsdouble x);
extern jsdouble
js_math_round_impl(jsdouble x);
#endif /* jsmath_h___ */