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

Revision 108 of this benchmark created on


Description

Rounding in all form possible

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
Math.floor(89.938 / 293.3);
Math.floor(83784 / 9289.2);
Math.floor(7 / 60);
Math.floor(987 / 226);
Math.floor(987.5 / 226.1);
ready
Math.round
Math.round(89.938 / 293.3);
Math.round(83784 / 9289.2);
Math.round(7 / 60);
Math.round(987 / 226);
Math.round(987.5 / 226.1);
ready
parseInt
parseInt(89.938 / 293.3, 10);
parseInt(83784 / 9289.2, 10);
parseInt(7 / 60, 10);
parseInt(987 / 226, 10);
parseInt(987.5 / 226.1, 10);
ready
Bitwise |
89.938 / 293.3 | 0;
83784 / 9289.2 | 0;
7 / 60 | 0;
987 / 226 | 0;
987.5 / 226.1 | 0;
ready
Bitwise
89.938 / 293.3 >> 0;
83784 / 9289.2 >> 0;
7 / 60 >> 0;
987 / 226 >> 0;
987.5 / 226.1 >> 0;
ready
Math.ceil
Math.ceil(8945.938 - 293.3) / 10;
Math.ceil(83784 - 289.2) / 10;
Math.ceil(7 / 60);
Math.ceil(987 / 226);
Math.ceil(987.5 / 226.1);
ready
~~
~~(89.938 / 293.3);
~~(83784 / 9289.2);
~~(7 / 60);
~~(987 / 226);
~~(987.5 / 226.1);
ready

Revisions

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