1.0.0 • Published 4 years ago

@alvarocastro/round v1.0.0

Weekly downloads
20
License
MIT
Repository
github
Last release
4 years ago

Round

NPM Build Status codebeat badge Coverage Status XO code style

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.