number-rounding

1.0.1 • Public • Published

Number Rounding Build Status

Install

npm install --save number-rounding

Import

var nr = require('number-rounding');
or
import nr from 'number-rounding';

Use

### Round nr.round(number, noOfDecimalPlaces);

nr.round(2.5); => 3
nr.round(2.5, 0); => 3
nr.round(-2.576, 2); => -2.58

### Round Up nr.roundUp(number, noOfDecimalPlaces);

### Round Down nr.roundDown(number, noOfDecimalPlaces);

### Round Half Up nr.roundHalfUp(number, noOfDecimalPlaces);

### Round Half Down nr.roundHalfDown(number, noOfDecimalPlaces);

### Round Half Even nr.roundHalfEven(number, noOfDecimalPlaces);

### Round Half Odd nr.roundHalfOdd(number, noOfDecimalPlaces);

Value Round Round Half Up Round Half Down Round Up Round Down Round Half Even Round Half Odd
1.7 2 2 2 2 1 2 2
1.5 2 2 1 2 1 2 1
1.1 1 1 1 2 1 1 1
0.7 1 1 1 1 0 1 1
0.5 1 1 0 1 0 0 1
0.1 0 0 0 1 0 0 0
-0.1 0 0 0 0 -1 0 0
-0.5 0 0 -1 0 -1 0 -1
-0.7 -1 -1 -1 0 -1 0 -1
-1.1 -1 -1 -1 -1 -2 -1 -1
-1.5 -1 -1 -2 -1 -2 -2 -1
-1.7 -2 -2 -2 -1 -2 -2 -2

Package Sidebar

Install

npm i number-rounding

Weekly Downloads

1,049

Version

1.0.1

License

MIT

Unpacked Size

68 kB

Total Files

16

Last publish

Collaborators

  • nandish