Brendan Eich (2013-07-09T23:14:34.000Z)
Jeff Walden wrote:
> I'm only commenting on the proposals that seem to be in the current draft, because I'm reviewing a patch that adds only those particular constants.  :-)  Just to be clear why I'm saying nothing about the other constants, neither to praise nor to disparage.
>
> On 03/09/2012 08:00 PM, Roger Andrews wrote:
>> Number.EPSILON == 2^-52
>> The difference between 1 and the smallest value>1 that is representable as a floating-point number.
>
> Why pick this particular epsilon?  Why not, say, 2**-1074 instead, as the difference between 0 and the next largest number?  Seeing only the name I'd have guessed 2**-1074.

See http://en.wikipedia.org/wiki/Machine_epsilon.

>> Number.MAX_INTEGER == 2^53 - 1
>> The maximum integer value that can be stored in a number without losing precision.
>> (OK, so technically 2^53 can be stored, but that's an anomaly.)
>
> Why discount the anomaly?  Looking at SpiderMonkey's source code, we have<http://mxr.mozilla.org/mozilla-central/search?string=%3C%3C%2053>  as vaguely representative of most of the places using a number like this, I think -- could be others not using the "<<  53" string, but that's probably a fair sample.  Ignore the RNG_DSCALE one, that's a red herring.  But all the others use 2**53 as the pertinent value.  (The dom/bindings/PrimitiveConversions.h hits using 2**53 -1 is a bug, I'm told, due to recent spec changes.)  So if this constant is to exist, and I think it's a fair constant to add, why would it not be 2**53?

I think you have a point! From 
http://en.wikipedia.org/wiki/Double-precision_floating-point_format,

"Between 2^52 =4,503,599,627,370,496 and 2^53 =9,007,199,254,740,992 the 
representable numbers are exactly the integers."

/be
domenic at domenicdenicola.com (2013-07-16T16:02:34.301Z)
Jeff Walden wrote:
> Why pick this particular epsilon?  Why not, say, 2^-1074 instead, as the difference between 0 and the next largest number?  Seeing only the name I'd have guessed 2^-1074.

See http://en.wikipedia.org/wiki/Machine_epsilon.

> Why discount the anomaly?  Looking at SpiderMonkey's source code, we have http://mxr.mozilla.org/mozilla-central/search?string=%3C%3C%2053  as vaguely representative of most of the places using a number like this, I think -- could be others not using the `"<<  53"` string, but that's probably a fair sample.  Ignore the RNG_DSCALE one, that's a red herring.  But all the others use 2^53 as the pertinent value.  (The dom/bindings/PrimitiveConversions.h hits using 2^53 -1 is a bug, I'm told, due to recent spec changes.)  So if this constant is to exist, and I think it's a fair constant to add, why would it not be 2^53?

I think you have a point! From http://en.wikipedia.org/wiki/Double-precision_floating-point_format,

"Between 2^52 =4,503,599,627,370,496 and 2^53 =9,007,199,254,740,992 the representable numbers are exactly the integers."