Closed Bug 686708 Opened 13 years ago Closed 6 years ago

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

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: brbaker, Unassigned)

References

Details

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-
The testcase ecma3/Number/e15_8_2_15.as "Infinity/Math.round(-0)" is actually checking for +Infinity instead of -Infinity
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
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.