Allen Wirfs-Brock (2013-10-30T15:47:12.000Z)
domenic at domenicdenicola.com (2013-11-03T22:26:53.358Z)
On Oct 29, 2013, at 8:54 PM, Oliver Hunt wrote: > What is the rational for this behaviour? > > Current Math.sign is a new, and unexpectedly complex API that doesn’t solve the common use case. It's just a matter of IEEE floats and consistency among the ES Math functions Consistant handling of NaN requires that Math.sign(NaN) produces NaN. So that means there needs to be at least four possible different return values from Math.sign. The fifth possible returned value derives from the handling of +/- 0. If you look at the other Math function you will see the all of them(except for Math.abs) that map 0 to 0 preserve the sign of the 0 input. Note that Java uses an identical definition for its signum function: http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#signum%28float%29 Finally, +0 and -0 compare as equal using both == and ===, so the impact of propagating -0 is small in mormal usage.?