0.1.3 • Published 6 years ago
number-roundto v0.1.3
number-roundto
NOTE: number-roundto was renamed to @extra-number/round.
Round number to specific precision.
Helps to deal with number precision problems.
const roundTo = require('number-roundto');
// roundTo(<value>, [precision])
// 1. round to specific precision
roundTo(9.135, 1);
// 9
roundTo(9.135, 1e-2);
// 9.14
roundTo(9.1357, 0.05);
// 9.15
// 2. round precision errors
0.1*0.2
// 0.020000000000000004
roundTo(0.1*0.2);
// 0.02