@alvarocastro/round
v1.0.0
Published
Round values up to an amount of decimals
Downloads
12
Maintainers
Readme
Round
Round values up to an amount of decimals, avoiding the floating point weirdness of JavaScript.
Install
npm install @alvarocastro/round
Usage
const round = require('@alvarocastro/round');
round(1.005);
// => 1.01
round(2.2222, 1);
// => 1.1
round(3, 5);
// => 3
round(number[, decimals = 2])
Returns the value rounded up to a given amout of decimals.
number
Type: Number
Value to round.
decimals
Type: Number
Default: 2
The amount of decimals to round the number to.