-
Notifications
You must be signed in to change notification settings - Fork 36
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
Getting TypeError: Amount must be an integer on test value 315.15
#35
Comments
315.15
315.15
Can also reproduce with |
Just give your money in cents/pennies eg:
|
The Money.fromDecimal function allows you to pass a third parameter of "rounder" which should be one of Math.ceil, Math.floor, or Math.round. You can then create your Money object without error like so: |
@mothman103182 Passing a "rounder" function just burdens the application using it. You just remove the issue in the library and let application handles it. Why not use big decimal instead for precise numeric operations? |
The code snippet below throws
Getting TypeError: Amount must be an integer
This line appears to be causing the problem:
js-money/lib/money.js
Line 119 in 10a4870
The result produced is
30014.999999999996
which is not the integer that's expected.The text was updated successfully, but these errors were encountered: