Mark S. Miller (2013-04-09T14:09:27.000Z)
github at esdiscuss.org (2013-07-12T02:26:59.444Z)
Consider instead the [Nat operation](<https://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/ses/startSES.js#412): ```js var MAX_NAT = Math.pow(2, 53); function Nat(allegedNum) { if (typeof allegedNum !== 'number') { throw new RangeError('not a number'); } if (allegedNum !== allegedNum) { throw new RangeError('NaN not natural'); } if (allegedNum < 0) { throw new RangeError('negative'); } if (allegedNum % 1 !== 0) { throw new RangeError('not integral'); } if (allegedNum > MAX_NAT) { throw new RangeError('too big'); } return allegedNum; } ``` This returns `allegedNum` only if it is a non-negative integer within the range of *consecutively* representable non-negative integers. For what uses of ToPositiveInteger would Nat not be better? Btw, given [the spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-9.1.11) `ToPositiveInteger` is badly misnamed. `+0` is not a positive integer. It is a non-negative integer. `+Infinity` is not an integer. `-Infinity `is neither positive nor an integer.