Flooring a number

JavaScript performance comparison

Test case created by T.J. Crowder

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var num = 26.9;

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Math.floor
if (Math.floor(num) !== 26) throw "Error";
pending…
Double bitwise NOT
if (~~num !== 26) throw "Error"; 
pending…
Bitwise OR with 0
if ((num | 0) !== 26) throw "Error";
pending…
Left shift with 0
if ((num << 0) !== 26) throw "Error";
pending…
Right shift with 0
if ((num >> 0) !== 26) throw "Error";
pending…
Unsigned right shift with 0
if ((num >>> 0) !== 26) throw "Error";
pending…
Bitwise AND with all-bits-on
if ((num & 0xFFFFFFFF) !== 26) throw "Error";
pending…
Double bitwise XOR with 0
if ((num ^ 0 ^ 0) !== 26) throw "Error";
pending…

Compare results of other browsers

Revisions

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

0 Comments