Math.round() does not handle -0 and -0.5 properly



7 years ago
7 years ago


(Reporter: brbaker, Unassigned)


(Blocks: 1 bug)

Bug Flags:
in-testsuite ?
flashplayer-qrb ?
flashplayer-bug -
flashplayer-triage +




7 years ago
ecma262, s15.8.2.15 round (x)
Returns the Number value that is closest to x and is equal to a mathematical integer. If two integer Number values are equally close to x, then the result is the Number value that is closer to +INFINITY. If x is already an integer, the result is x.

- If x is -0, the result is -0.

Math.round(-0); --> 0 (should be -0)
Infinity/Math.round(-0) --> +Infinity (should be -Infinity)
Flags: in-testsuite?
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
Flags: flashplayer-bug-

Comment 1

7 years ago
The testcase ecma3/Number/ "Infinity/Math.round(-0)" is actually checking for +Infinity instead of -Infinity

Comment 2

7 years ago
Another point in the specification that is not handled properly is:

- If x is less than 0 but greater than or equal to -0.5, the result is -0.

Math.round(-0.49); --> 0 (should be -0)
Infinity/Math.round(-0.49) --> +Infinity (should be -Infinity)
Summary: Math.round() does not handle -0 properly → Math.round() does not handle -0 and -0.5 properly
You need to log in before you can comment on or make changes to this bug.