Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
toFixed vs toPrecision vs Math.round() vs Math.Floor
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0
Browser:
Firefox 127
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
(Math.round(*1000000)/1000000)
1782.9M/s
Math.floor( * 1000000)
1775.1M/s
toFixed(6)
23.9M/s
toPrecision(6).toString()
18.1M/s
View exact numbers
Test name
Executions per second
✓
(Math.round(*1000000)/1000000)
1,782,905,216 Ops/sec
Math.floor( * 1000000)
1,775,076,096 Ops/sec
toFixed(6)
23,949,510 Ops/sec
toPrecision(6).toString()
18,116,802 Ops/sec
Script Preparation code:
var someFloat = 0.123456789;
Tests:
toFixed(6)
someFloat.toFixed(6);
toPrecision(6).toString()
someFloat.toPrecision(6);
(Math.round(*1000000)/1000000)
(Math.round(someFloat*1000000)/1000000);
Math.floor( * 1000000)
Math.floor(someFloat * 1000000);