parseInt VS parseFloat (v10)

Revision 10 of this benchmark created on


Description

Exactly what the name says. Finally, the gloves are off.

VERDICT!

Chrome likes parseFloat more, unless you're trying to actually grab the integer value out of a floating-point string.

Firefox is just the opposite! What a country!

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt (Integer)
parseInt("123px");
ready
parseFloat (Integer)
parseFloat("123px");
ready
parseInt (Float)
parseInt("123px");
ready
parseFloat (Float)
parseFloat("123px");
ready
Plus sign
+"123px"
ready
parseInt (Integer, 10)
parseInt("123px", 10)
ready
parseInt (Float, 10)
parseInt("123px", 10)
ready
binary
~~"123px"
ready
to numeric + binary
~~+"123px"
ready
one more binary
"123px"^0
ready
Plus Sign Int
+"123px"
ready
~~"0px"
ready
~~"-1px"
ready
"0px"^0
ready
"-1px"^0
ready

Revisions

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