Math.floor vs Math.round vs parseInt vs Bitwise (v19)

Revision 19 of this benchmark created on


Description

Rounding in all form possible

Preparation HTML

var a;

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
a = Math.floor(89.938 / 293.3);
a = Math.floor(83784 / 9289.2);
a = Math.floor(7 / 60);
ready
Math.round
a = Math.round(89.938 / 293.3);
a = Math.round(83784 / 9289.2);
a = Math.round(7 / 60);
ready
parseInt
a = parseInt(89.938 / 293.3);
a = parseInt(83784 / 9289.2);
a = parseInt(7 / 60);
ready
Bitwise |
a = (89.938 / 293.3) | 0;
a = (83784 / 9289.2) | 0;
a = (7 / 60) | 0;
ready
Bitwise >>
a = (89.938 / 293.3) >> 0;
a = (83784 / 9289.2) >> 0;
a = (7 / 60) >> 0;
ready
Bitwise ~~
a = ~~(89.938 / 293.3);
a = ~~(83784 / 9289.2);
a = ~~(7 / 60);
ready
Bitwise <<
a = (89.938 / 293.3) << 0;
a = (83784 / 9289.2) << 0;
a = (7 / 60) << 0;
ready

Revisions

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