diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c index b2e61ae64..5475b347d 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c @@ -359,7 +359,8 @@ ecma_builtin_math_dispatch_routine (uint16_t builtin_routine_id, /**< built-in w { if (ecma_number_is_nan (x) || ecma_number_is_zero (x) - || ecma_number_is_infinity (x)) + || ecma_number_is_infinity (x) + || fmod (x, 1.0) == 0) { /* Do nothing. */ } diff --git a/tests/jerry/math-round.js b/tests/jerry/math-round.js index 36f1fdb33..fe1aa9c01 100644 --- a/tests/jerry/math-round.js +++ b/tests/jerry/math-round.js @@ -35,3 +35,17 @@ assert (Math['round'](-0.7) === -1.0); assert (Math['round'](-1.2) === -1.0); assert (Math['round'](-1.7) === -2.0); assert (Math['round'](-1.5) === -1.0); + +assert (Math['round'](1) === 1); +assert (Math['round'](-1) === -1); + +for (var n = 1; n <= 53; n++) +{ + var x = Math.pow(2, n) + assert (Math['round'](x - 1) === x - 1); + assert (Math['round'](x) === x); + assert (Math['round'](x + 1) === x + 1); + assert (Math['round'](-x - 1) === -x - 1); + assert (Math['round'](-x) === -x); + assert (Math['round'](-x + 1) === -x + 1); +}