We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Round a number to specific precision.
Similar: floor, ceil, round.
function round(x, pre?) // x: a number // pre: to precision [1]
const xmath = require('extra-math'); xmath.round(9.135, 1); // → 9 xmath.round(9.135, 1e-2); // → 9.14 xmath.round(9.1357, 0.05); // → 9.15 0.1 + 0.2 // → 0.30000000000000004 (why?) xmath.round(0.1 + 0.2, 1e-12); // → 0.3 (nice!)