bignumber.jsを使った小数点以下の計算
1 2 3 4 5 6 7 8 9 10 11 12 |
// https://github.com/MikeMcl/bignumber.js/blob/master/bignumber.js const BigNumber = require('./bignumber.js') const p = console.log const a = new BigNumber(0.000000000000000001) const b = new BigNumber(1000000000) const c = a.multipliedBy(b) p("a * b = c") p("a : " + a.toFixed()) p("b : " + b.toFixed()) p("c : " + c.toFixed()) |
1 2 3 4 |
a * b = c a : 0.000000000000000001 b : 1000000000 c : 0.000000001 |