Very old bug in ECMAScript spec

# Waldemar Horwat (12 years ago)

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.