Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The result is "9.9999999999999999999" of 10/3*3 ? #54

Closed
ghost opened this issue Jun 1, 2017 · 1 comment
Closed

The result is "9.9999999999999999999" of 10/3*3 ? #54

ghost opened this issue Jun 1, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 1, 2017

I tried the fllow code on https://npm.runkit.com/decimal.js

var decimalJs = require("decimal.js")

new decimalJs
.Decimal('10')
.dividedBy('3')
.mul('3')
.toString()

Expect: 10
Actual: "9.9999999999999999999"

@MikeMcl
Copy link
Owner

MikeMcl commented Jun 1, 2017

Please look at the result of Decimal('10').dividedBy('3'). Mathematically, that number multiplied by 3 is 9.9999999999999999999 not 10. This library does not store values as fractions.

@MikeMcl MikeMcl closed this as completed Jun 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant