bitwise even vs modulo even

Benchmark created on


Setup

function isEven_bit(n) { return !(n-~~(n)) && !(n&1); }
    function isEven_mod(n) { return !(n%2); }

Test runner

Ready to run.

Testing in
TestOps/sec
bitwise
isEven_bit(0);
isEven_bit(1);
isEven_bit(2);
isEven_bit(2.999);
isEven_bit(13.37);
isEven_bit(3.14);
ready
modulo
isEven_mod(0);
isEven_mod(1);
isEven_mod(2);
isEven_mod(2.999);
isEven_mod(13.37);
isEven_mod(3.14);
ready

Revisions

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