1.0.1 • Published 5 years ago

number-rounding v1.0.1

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

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);

ValueRoundRound Half UpRound Half DownRound UpRound DownRound Half EvenRound Half Odd
1.72222122
1.52212121
1.11112111
0.71111011
0.51101001
0.10001000
-0.10000-100
-0.500-10-10-1
-0.7-1-1-10-10-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