0

If I've got a BigNumber (http://mikemcl.github.io/bignumber.js/) with a particular DECIMAL_PLACES:

let BN = BigNumber.another({ DECIMAL_PLACES: 0 })
a = new BN(10)

How can I change the number of decimal places used for a particular operation?

For example:

> a.div(3)
3
> a.setDecimalPlaces(1).div(3)
3.3

I know I can create a new BigNum(…):

> (new BigNumber(a)).div(3)
3.333…

But that seems less than ideal.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
David Wolever
  • 148,955
  • 89
  • 346
  • 502

0 Answers0