Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Teste Truncar numero
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 120
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
toFixed
229651.9 Ops/sec
Round
705876.2 Ops/sec
floor
700182.2 Ops/sec
Bitwise
149503312.0 Ops/sec
Math.trunc
712237.8 Ops/sec
Tests:
toFixed
let numero = 123.45678; let resultado = numero.toFixed(2); // "123.46" como string resultado = Number(resultado); // Converte de volta para número, se necessário
Round
let numero = 123.45678; let resultado = Math.round(numero * 100) / 100; // 123.46
floor
let numero = 123.45678; let resultado = Math.floor(numero * 100) / 100; // 123.45
Bitwise
let numero = 123.45678; let resultado = (numero * 100 | 0) / 100; // 123.45
Math.trunc
let numero = 123.45678; let resultado = Math.trunc(numero * 100) / 100; // 123.45