MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.64k stars 741 forks source link

How to get accurate result from simple multiplication? #274

Closed RatchapongT closed 3 years ago

RatchapongT commented 3 years ago
(new BigNumber(11).div(new BigNumber(10))).multipliedBy(new BigNumber(10).div(new BigNumber(11))).toFormat()
"1.000000000000000000001"

What are available techniques to deal with such case? Thank you!

MikeMcl commented 3 years ago

This kind of question is best asked on a site such as stackoverflow.