parseInt VS parseFloat (v2)

Revision 2 of this benchmark created by Brian Blakely 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)
parseFloat("123.123px");
ready
parseFloat (Float)
parseFloat("123.123px");
ready
Round and parseFloat (Float)
Math.round(parseFloat("123.123px"));
ready

Revisions

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