Overview:
While performing a Math.round() calculation on any decimal between -0.5 and zero, the Math.round() function returns NEGATIVE ZERO.
Behavior verified on Mac OSX 10.9.5, on:
Google Chrome 9.0.2171.71
Mozilla Firefox 33.1 & 34.0
Expected behavior observed on:
Safari Version 7.1 (9537.85.10.17.1)
Steps to Reproduce:
1) Open the JavaScript console in a current browser.
2) Enter: Math.round(-0.5)
Actual Results:
-0
Expected Results:
0
Additional Information:
The negative sign does not break any Math-based calculations that I am aware of, but if you are expecting a number that you can use as an index in an array, the index will not be found.
note that
anArray[-0]
is equivalent to
anArray["0"]
Don't think we want to change Math.round semantics at this point, but proposals can be made on es-discuss.