Ecma262: Possibly improper definition of Number.EPSILON constant

Created on 18 Feb 2020  路  6Comments  路  Source: tc39/ecma262

The 20.1.2.1 Number.EPSILON says:

The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 that is representable as a Number value

The definition is incorrect since in that case we end up with negative value for constant. I propose to make an amendment to definition like:

The value of Number.EPSILON is the absolute difference between 1 and the smallest value greater than 1 that is representable as a Number value

needs editorial changes question

All 6 comments

We could also just define it as 2^-52 (hopefully in hex form though), since we know we're using binary64.

I'm confused, how do we end up with a negative value? The prose here doesn't, to me, read as "subtract from 1", it reads as "what is the difference between the two", which is always a positive value.

@ljharb i do distinctly recall from math class that "the difference of x and y" is x minus y, which would result in a negative value here. that being said, i think it is easy to read it in either way, so i would be in favor of rewording it.

Echoing @ljharb, the power really is in the preposition鈥擾between_ is symmetric, _of_ and _from_ are not. The image of "difference between X and Y" should be "distance between X and Y on the real line", but if this isn't clear then I suppose we should find a phrasing that doesn't use the word 'difference'. 馃槙

I'd be open to rephrasing it, sure. How about something like:

The value of Number.EPSILON is _x_ - 1, where _x_ is the smallest value greater than 1 that is representable as a Number value

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bkardell picture bkardell  路  3Comments

AlexSHoffman picture AlexSHoffman  路  3Comments

erights picture erights  路  4Comments

codehag picture codehag  路  3Comments

moonformeli picture moonformeli  路  3Comments