Float to Int conversion comparison (v2)

Revision 2 of this benchmark created by Robert Koritnik on


Description

decimals truncation for positives and negatives with different techniques

Test runner

Ready to run.

Testing in
TestOps/sec
Bitwise OR
(Math.random() * 1000 - 500) | 0;
ready
Bitwise NOT
~~(Math.random() * 1000 - 500)
ready
Math.floor
var n = Math.random() * 1000 - 500;
return n < 0 && Math.ceil(n) || Math.floor(n);
ready
parseInt
parseInt(Math.random() * 1000 - 500)
ready

Revisions

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