Test name | Executions per second |
---|---|
Number(v.toPrecision(p)) | 1231508.5 Ops/sec |
_p=Math.pow(10,p-Math.ceil(Math.log10(v)));Math.round(v*_p)/_p | 896504.2 Ops/sec |
var v=982173129.981279
var p=12
Number(v.toPrecision(p));
var _p=Math.pow(10,p-Math.ceil(Math.log10(v)));Math.round(v*_p)/_p;