some fixes for javascript Math object

Review Request #128672 - Created Aug. 13, 2016 and updated

Viktor Mv
buschinski, maksimmelnikau

some fixes for Math methods:

Math.exmp1 - the name should be expm1;
Math.hypot.length should give 2;
Math.abs(+0) should give positive zero;
Math.round(0.49999999999999994) should give 0, not 1, Math.round(-9007199254740991) should give -9007199254740991, not -9007199254740990, Math.round(+9007199254740991) should give +9007199254740991, not +9007199254740992;
Math.hypot - Implementations should take care to avoid the loss of precision from overflows and underflows that are prone to occur in naive implementations when this function is called with two or more arguments. (;
Math.imul() should give 0;
Math.asinh was not exposed;
Math.LOG10E has an inaccurate value

I am sorry, but I did not compile this code, so there could be some mistakes... The implementations were tested although.


  • 1
  • 0
  • 0
  • 1
Description From Last Updated
Why this change? Albert Astals Cid Albert Astals Cid
Viktor Mv
Viktor Mv
Viktor Mv
Viktor Mv
Viktor Mv
Review request changed


Albert Astals Cid

The implementations were tested although.

Could you share the tests you did?

src/kjs/math_object.cpp (Diff revision 2)

Why this change?

  1. 1.0 / log(10.0) gives 0.43429448190325176, not 0.4342944819032518

  2. 0.43429448190325176 is just 0.4342944819032518 with a digit more of precision.

Aleix Pol Gonzalez

This code clearly misses some tests. I'm also concerned that you didn't build it, let alone test it at all. Or ran current kjs autotests.