Hacker News new | ask | show | jobs
by orra 1942 days ago
I can't agree with your pedantry here.

> When an integer can be reliably represented, that presumably

You are right that the wording is not precise, but now you're putting a lot of meaning into what you admit is an assumption.

> means that JavaScript's definition of the Number type is such that it guarantees that a given integer can be represented exactly by the Number type. It doesn't mean you can safely do arbitrary integer arithmetic

Who said arbitrary? The natural numbers are canonically represented by a successor function, denoted S(n). So we're talking about the highest natural that can be represented as such.

1 comments

> you're putting a lot of meaning into what you admit is an assumption

Can you suggest another interpretation? It's a point about representing a number, and is not a point about arithmetic, so I'm not seeing what else it could mean.

Either way we're agreed that it wants reworking. Technical documentation should not be incorrect, as I believe it to be, and it should not be ambiguous, as you believe it to be.

> Who said arbitrary?

Look at what I was responding to: After 2^53 - 1 you get incorrect results when dealing with integers, making the results not "reliable". That's not very precise, as dealing with might refer to the problem of exactly representing the integer values in the Number type, or it might refer to the problem of doing arithmetic with those values and getting exact results.

To rephrase my point: with the exception of 0, there is no Number value x such that, for all integer Number values y, the integer x + y can be represented exactly as a Number. It's not 'safe' to compute Number.MAX_SAFE_INTEGER + 1 despite that both terms are 'safe' integers.

Which is to say, we need to be clear that we're reasoning about the problem of exactly representing integer values in the Number type.

> The natural numbers are canonically represented by a successor function, denoted S(n). So we're talking about the highest natural that can be represented as such.

I don't see your point here. I've already discussed the difference between Number.MAX_SAFE_INTEGER and the much greater integer Number.MAX_VALUE.