parseFloat vs Math.round

Benchmark created on


Description

https://stackoverflow.com/a/28515376/17516598

Setup

function toFloat(number) {
	return Math.round(number * 100) / 100
}

Test runner

Ready to run.

Testing in
TestOps/sec
parseFloat("100.123456");
parseFloat("100.123456")
ready
toFloat("100.123456")
toFloat("100.123456")
ready

Revisions

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