toFormat
Adds a toFormat
instance method to big.js or decimal.js.
Install
Node.js
$ npm install toformat
Browser
Use
Node.js
Big = Big = Big x = 987654321x // '9,876.54' // Three different ways of setting a formatting propertyBigformatdecimalSeparator = ','xformatgroupSeparator: ' 'x // '98 76,5'
Browser
x = 987654321x // '9,876.54'
Further examples:
// The format object added to the Decimal constructor by this library.Decimalformat = decimalSeparator: '.' groupSeparator: ',' groupSize: 3 secondaryGroupSize: 0 fractionGroupSeparator: '' fractionGroupSize : 0 x // 123,456,789.987654321x // 123,456,789.98 // Add a format object to a Decimal instance.xformat = decimalSeparator: ',' groupSeparator: '' x // 123456789,987654321 format = decimalSeparator: '.' groupSeparator: ' ' groupSize: 3 fractionGroupSeparator: ' ' fractionGroupSize : 5 // Pass a format object to the method call.x // 123 456 789.98765 4321x // 123 456 789.9877x // 123 456 789.98
Test
$ npm test