Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
toFixed vs toPrecision vs Math.round() 2 decimal
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
toFixed 2 decimals
34103324.0 Ops/sec
toPrecision 2 decimals
50474584.0 Ops/sec
Math.round 2 decimals
264802176.0 Ops/sec
Script Preparation code:
var someFloat = 0.123456789;
Tests:
toFixed 2 decimals
someFloat.toFixed(2);
toPrecision 2 decimals
someFloat.toPrecision(2)
Math.round 2 decimals
Math.round(someFloat * 100 + Number.EPSILON) / 100