rounding positive values

JavaScript performance comparison

Revision 2 of this test case created by Filip Minev

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var v = 12345.6789, r;
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
shift right
r = v>>>0; // result 12345
pending…
Math.floor
r = Math.floor(v); // result 12345
pending…
~~
r = ~~v; // result 12345
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. Here’s a list of current revisions for this page:

0 comments

Add a comment