Skip to content

Commit 7685afd

Browse files
ossy-szegedakosthekiss
authored andcommitted
Fix Math.pow (#2985)
The Math.pow implementation calls libm's pow. The ISO C and ES5.1 standards differ on some special cases of pow. jerry-libm is already ES5.1 conform, but system libm libraries on Linux and Windows aren't. Math.pow(NaN, +/-0.0) is NaN on Windows and Linux with system libm, but should be 1.0 according to ES5.1 / 15.8.2.13. This patch handles this special case in Math.pow instead of calling pow of libm. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
1 parent ea577d6 commit 7685afd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-math.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ ecma_builtin_math_dispatch_routine (uint16_t builtin_routine_id, /**< built-in w
412412
/* Handle differences between ES5.1 and ISO C standards for pow. */
413413
x = ecma_number_make_nan ();
414414
}
415+
else if (ecma_number_is_zero (y))
416+
{
417+
/* Handle differences between ES5.1 and ISO C standards for pow. */
418+
x = (ecma_number_t) 1.0;
419+
}
415420
else
416421
{
417422
x = DOUBLE_TO_ECMA_NUMBER_T (pow (x, y));

0 commit comments

Comments
 (0)