Package Exports
- round.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (round.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
round.js
Round a number to a specific number, by decimal or nearest
Installation
Install the package from npm
$ npm install --save round.jsUsage
import round from 'round.js';
round(1.234, 2);
//=> 1.23
round.up(1.234, 2);
//=> 1.24
round.down(1.234, 2);
//=> 1.23
round.to(11, 5);
//=> 10
round.next(11, 10);
//=> 20
round.prev(11, 10);
//=> 10API
round.js: Tiny number-parser lib
Returns Number
round
Rounds a floating number to nearest number / float based on precision
Parameters
Numberprecision
round(1.234, 2);
//=> 1.23round.up
Rounds a floating up number to nearest number / float based on precision
Parameters
Numberprecision
round.up(1.234, 2);
//=> 1.24round.down
Rounds a floating down number to nearest number / float based on precision
Parameters
Numberprecision
round.down(1.234, 2);
//=> 1.23round.near
Increment or decrement the number until it reaches the nearest near number
Parameters
Numbernear
round.near(11, 5);
//=> 10
round.near(13, 5);
//=> 15round.next
Increment the number until it reaches the next next number
Parameters
Numbernext
round.next(11, 5);
//=> 15round.prev
Decrement the number until it reaches the previous prev number
Parameters
Numberprev
round.prev(11, 5);
//=> 10