# Clarify integer and safe integer resolution

Mark S. Miller erights at google.com
Thu Aug 29 11:39:25 PDT 2013

```What I remember, rephrased using code

> Number.MAX_SAFE_INTEGER = (2^53)-1;

yes. Presumably

Number.MIN_SAFE_INTEGER = -Number.MAX_SAFE_INTEGER;

Number.isSafeInteger(n) {
return typeof n === 'number' &&
Math.round(n) === n &&
Number.MIN_SAFE_INTEGER <= n &&
n <= Number.MAX_SAFE_INTEGER;
}

This has the important guarantee that

isSafeInteger(a) && isSafeInteger(b) && isSafeInteger(a+b) together imply
that a+b is the accurate sum of a and b.

Also

isSafeInteger(NaN) // false
isSafeInteger(new Integer(2)) // false
isSafeInteger(-0) // true
isSafeInteger(Infinity) // false

We also decided that toInteger is not needed given the other similar

As for Number.isInteger, I don't remember.

On Thu, Aug 29, 2013 at 11:00 AM, Rick Waldron <waldron.rick at gmail.com>wrote:

> At the last TC39 meeting we discussed the addition of the following
> items[0]:
>
> Number.MAX_SAFE_INTEGER = (2^53)-1
>
> Number.isInteger
>   - Infinity => false
>   - NaN => false
>   - value !== truncated value => false
>   - -0 => true
>
> Number.isSafeInteger
>   - -0 => true
>
>
>  This resolution of record doesn't include a consensus on these extensions
> as defined, but IIRC there was consensus on Mark's proposal. Jeff Walden
> noted[1] that there was no clear resolution and I apologize for this
> oversight.
>
> Rick
>
> [0]
> https://github.com/rwaldron/tc39-notes/blob/master/es6/2013-07/july-25.md#59-semantics-and-bounds-of-numberisinteger-and-numbermax_integer
>
> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=885798#c12
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>

--
Cheers,
--MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130829/d446cce3/attachment.html>
```