Overview:
While performing a Math.ceil() calculation on any decimal between -1 and zero, the Math.ceil() 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.ceil(-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.
(In reply to Clif from comment #0)
> 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.
Are you sure that Safari returns +0 for `Math.ceil(-0.5)`? Maybe the JavaScript console is just misleading you by displaying -0 as 0. Have you tried to evaluate the expression `1 / Math.ceil(-0.5)`, that one should result in `-Infinity`.
Having said that, the statement about negative zero is not applicable as array index is wrong, negative zero is treated the same way as positive zero for array indexing. And the definition for Math.ceil (*) cannot be changed otherwise we'd be violating the IEEE-754 standard.
(*) and Math.round (bug 3401)
Will not be changing Math.ceil semantics. All implementations seem to agree today.