Number flooring

JavaScript performance comparison

Revision 12 of this test case created by ThinkingStiff

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var foo = 5.98897982734987897234234;
   
};
</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
parseInt
var result = parseInt(foo, 10);
 
pending…
~~
var result = ~~ (foo);
 
pending…
Math.floor
var result = Math.floor(foo, 2);
 
pending…
toFixed
var result = foo.toFixed(2);
 
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