MikeMcl / decimal.js

An arbitrary-precision Decimal type for JavaScript
http://mikemcl.github.io/decimal.js
MIT License
6.35k stars 480 forks source link

Error in multiplication #196

Closed RobbeCl closed 2 years ago

RobbeCl commented 2 years ago

When using multiplication, it is not calculating correctly. I don't know if it is intended to work this way or maybe something else.

The example: Decimal.Decimal(365).mul(2.7397260273972600000000).toNumber() returns "999.9999999999999" while the answer should be 1000 exactly.

I thought this library would solve this issue or am I missing something?

MikeMcl commented 2 years ago

Yes, it certainly seems like you are missing something.

It is obvious at a glance that the exact answer could not possibly be 1000.