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

NEW
Unassigned

Status

7 years ago
7 years ago

People

(Reporter: brbaker, Unassigned)

Tracking

(Blocks: 1 bug)

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

Details

(Reporter)

Description

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-
(Reporter)

Comment 1

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

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.