float to int cast (v2)

Revision 2 of this benchmark created by rmaksim on


Description

Casting a float to int

Preparation HTML

<script>
    var somefloat = 100 + (Math.random() * 1000);
    var theint;
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Normal Parse Int
theint = parseInt(somefloat);
 
ready
Double Binary Neg
theint = ~~somefloat;
ready
Math Floor
theint = Math.floor(somefloat);
ready
to Fix
theint = somefloat.toFixed();
ready
Binary Or
theint = somefloat|0;
ready
Binary LShift 0
theint = somefloat << 0;
ready
Binary RShift 0
theint = somefloat >> 0;
ready
^
theint = somefloat ^ 0;
ready

Revisions

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