jasnell / proposal-istypes

TC-39 Proposal for additional is{Type} APIs
201 stars 7 forks source link

A repeated typo is causing all of the isIntX definitions to be wrong #12

Closed rwaldron closed 7 years ago

rwaldron commented 7 years ago

I'll only copy isInt8, because they all have the same issue, so no reason to repeat myself:

Number.isInt8(arg) Returns true if Number.isNumber(arg) is true and arg is an 8-bit signed integer in the range -2^7 <= arg <= -2^7-1.

When implemented as shown:

function isInt8(arg) {
  return (-Math.pow(2, 7)) <= arg <= (-Math.pow(2, 7) - 1);
}

isInt8(255) === false;
isInt8(127) === false;
isInt8(120) === false;
isInt8(1) === false;
isInt8(-1) === false;

This can likely be rolled into the fixes for #11, eg:

Number.isInt8(arg)

  1. If Type(arg) is Number and arg is an integer in the range -27 through 27-1, inclusive, return true.
  2. Return false.
rwaldron commented 7 years ago

Note that there are two defects:

jasnell commented 7 years ago

Sigh. Sorry about that. That's what I get for not proofreading

rwaldron commented 7 years ago

Don't sweat it! All quick fixes :)