@alvarocastro/round

1.0.0 • Public • Published

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.

/@alvarocastro/round/

    Package Sidebar

    Install

    npm i @alvarocastro/round

    Weekly Downloads

    27

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    5.11 kB

    Total Files

    7

    Last publish

    Collaborators

    • alvarocastro