Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
floor vs trunc vs bit shift
the fastest way to get an integer from a float
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
trunc
1030.7M/s
bitshift
1023.3M/s
floor
1017.5M/s
View exact numbers
Test name
Executions per second
✓
trunc
1,030,661,632 Ops/sec
bitshift
1,023,328,960 Ops/sec
floor
1,017,464,256 Ops/sec
Script Preparation code:
var x = 23.45
Tests:
floor
var r = Math.floor(x)
trunc
var r = Math.trunc(x)
bitshift
var r = x >> 0