-
Notifications
You must be signed in to change notification settings - Fork 188
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
Documentation regarding creation of Dinero objects from floats in Dinero V2 #761
Comments
Hi @quophyie. Recently, I came across an article working with money in software. It should explain why using floats to create currency objects is not encouraged. The Dinero.js v2 docs even explicitly states that it is a bad idea. |
You're right @ch1booze though it's sometimes still necessary to convert, for example from 3rd sources which might give you string floats. |
Hi @ch1booze, The docs and code as provided in the docs give precedence to using the If the caller of the function does not want the |
In FAQ docs in Dinero v2-alpha i.e (https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats, follows from #58), the code is written as follows
Although the above is not incorrect, per se, it gives precedence to
currency.exponent
whereas I think it should give precedence to the user suppliedscale
. This is because when the caller calls the function with a scale, the caller would expect the supplied scale to be applied first and then if that fails, then try and apply the default scale of the currencySo I propose,
The text was updated successfully, but these errors were encountered: