Here's a cute little bug in the ECMAScript spec I discovered when following
up the implications of safe integers we were discussing today:
15.8.2.15 Math.round has the following note:
The value of Math.round(x) is the same as the value of Math.floor(x+0.5),
except when x is -0 or is less than 0 but greater than or equal to
-0.5; for these cases Math.round(x) returns -0, but
Math.floor(x+0.5) returns +0.
Here's a cute little bug in the ECMAScript spec I discovered when following
up the implications of safe integers we were discussing today:
15.8.2.15 Math.round has the following note:
The value of *Math.round(x)* is the same as the value of *Math.floor(x+0.5)*,
except when *x* is -0* *or* *is less than 0 but greater than or equal to
-0.5; for these cases *Math.round(x)* returns -0, but
*Math.floor(x+0.5)*returns
+0.
This is false.
Math.round(4503599627370497) returns 4503599627370497.
Math.floor(4503599627370497+0.5) returns 4503599627370498.
Waldemar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130725/e6d647ec/attachment.html>
Here's a cute little bug in the ECMAScript spec I discovered when following up the implications of safe integers we were discussing today:
15.8.2.15 Math.round has the following note:
The value of Math.round(x) is the same as the value of Math.floor(x+0.5), except when x is -0 or is less than 0 but greater than or equal to -0.5; for these cases Math.round(x) returns -0, but Math.floor(x+0.5) returns +0.
This is false.
Math.round(4503599627370497) returns 4503599627370497.
Math.floor(4503599627370497+0.5) returns 4503599627370498.