float to int cast (v3)

Revision 3 of this benchmark created 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
Right shift, zero fill
theint = somefloat >>> 0
ready

Revisions

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