royNiladri / js-big-decimal

Work with large numbers on the client side with high precision.
https://www.npmjs.com/package/js-big-decimal
MIT License
156 stars 28 forks source link

2.00 / 0.5 = 40.00000000 #18

Closed valerashylin closed 5 years ago

valerashylin commented 6 years ago

Inconsistency in treating decimal digits in division:

Thus, bigDecimal.divide('2.00', '0.5') = 40.00000000 However, bigDecimal.divide('2.00', '0.50') = 4.00000000

Workaround: bigDecimal.divide( bigDecimal.round('2.00', 2), bigDecimal.round('0.5', 2)) = 4

npm

bigdecimal v.1.2.1 image

gaoming13 commented 5 years ago
let a = new bigDecimal('0.11005')
let b = new bigDecimal('0.1')
console.log(a.divide(b))

console.log(bigDecimal.divide('0.11005', '0.1'))

console.log(bigDecimal.divide(bigDecimal.round('0.11005', 16), bigDecimal.round('0.1', 16)))
bigDecimal { value: '11005.00000000' }
11005.00000000
1.10050000
royNiladri commented 5 years ago

@gaoming13 and @valerashylin Deployed patch for the reported issues. Sorry for the delay. Please use v1.2.2 and let know.