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:
one year ago
Math.round 2 decimals
264.8M/s
toPrecision 2 decimals
50.5M/s
toFixed 2 decimals
34.1M/s
View exact numbers
Test name
Executions per second
✓
Math.round 2 decimals
264,802,176 Ops/sec
toPrecision 2 decimals
50,474,584 Ops/sec
toFixed 2 decimals
34,103,324 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