Fixing Math.pow
The Math.pow implementation relies on libm's pow. However, the ISO C
and ES5.1 standards differ on pow:
* `x ** NAN` is NAN in ES but `+1 ** y` is 1 in C
* `+-1 ** +-INF` is NAN in ES but 1 in C
This patch:
* Modifies the Math.pow implementation to handle the special cases
instead calling pow.
* Adds a test case to jerry-test-suite as it did not test
`Math.pow(1,NaN)`.
* Fixes jerry-libm's pow, as it was not standard conforming, which
helped hiding the error in Math.pow.
* Updates the unit test for libm.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -330,6 +330,11 @@ check_double ("pow (1.0, 1.0)", pow (1.0, 1.0), 1.00000000000000000000E+00);
|
||||
check_double ("pow (1.0, -1.0)", pow (1.0, -1.0), 1.00000000000000000000E+00);
|
||||
check_double ("pow (-1.0, 1.0)", pow (-1.0, 1.0), -1.00000000000000000000E+00);
|
||||
check_double ("pow (-1.0, -1.0)", pow (-1.0, -1.0), -1.00000000000000000000E+00);
|
||||
check_double ("pow (1.0, INFINITY)", pow (1.0, INFINITY), 1.00000000000000000000E+00);
|
||||
check_double ("pow (1.0, -INFINITY)", pow (1.0, -INFINITY), 1.00000000000000000000E+00);
|
||||
check_double ("pow (-1.0, INFINITY)", pow (-1.0, INFINITY), 1.00000000000000000000E+00);
|
||||
check_double ("pow (-1.0, -INFINITY)", pow (-1.0, -INFINITY), 1.00000000000000000000E+00);
|
||||
check_double ("pow (1.0, NAN)", pow (1.0, NAN), 1.00000000000000000000E+00);
|
||||
check_double ("pow (-1.0, NAN)", pow (-1.0, NAN), NAN);
|
||||
check_double ("pow (INFINITY, 0.0)", pow (INFINITY, 0.0), 1.00000000000000000000E+00);
|
||||
check_double ("pow (INFINITY, -0.0)", pow (INFINITY, -0.0), 1.00000000000000000000E+00);
|
||||
|
||||
Reference in New Issue
Block a user