Integer Validity (v8)

Revision 8 of this benchmark created by PetkaAntonov on


Preparation HTML

<script>
function isInt1(n) {
    return typeof n === "number" && (n % 1) === 0;
    /*...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*/
}

function isInt2(n) {
    return n === parseInt(n);
    /*...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*/
}
</script>

Setup

var a = 12;
    var b = 34.5;
    var c = Infinity;

Test runner

Ready to run.

Testing in
TestOps/sec
Typeof and modulus operator
if (!isInt1(a)) die
if (isInt1(b)) die
if (isInt1(c)) die
ready
Using parseInt
if (!isInt2(a)) die
if (isInt2(b)) die
if (isInt2(c)) die
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.