-
Notifications
You must be signed in to change notification settings - Fork 45
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
Fix for rounded value in ExchangeRate #60
Comments
Hi! Sorry for the late response, somehow didn't get a notification. Rounding to 6 decimals
Also other sources as Accounting Rules and how financial applications handle exchange rates. If you see the sources, most of them agree on 5 or 6 decimals. If you even look closer, they mean 5 to 6 significant figures, so the current implementation I need to look up the sources with accounting examples, but they prove that this rounding was good enough in conversions. Accounting apps seems to store this with max 6 decimals, because more would not improve your conversions. Only with very unlikely big amounts of money, you would lose or gain a penny., which seems to be acceptable. So for these reasons the 6 decimals were chosen, to kind of forcibly get rid of the non significant figures. The override with a parameter for the number of decimals wasn't created (yet), because it seems to be kind of an golden rule when working with exchange rates and I want to prevent consumers to do the wrong thing. I am happy to discuss this with sources/use cases/etc to improve the NodaMoney. I just want a library that helps app builders to use the most common rules by default (and where needed could be overridden). Why is there a constructor accepting a double in the first place?
|
Hi! I'm using NodaMoney with custom currencies and exchange rates and was very happy to see that custom currencies can be initialized with a high number of decimals. Recently, however, I've discovered that the constructor of the
ExchangeRate
rounds the instantiated exchange rate value to 6 decimals, which essentially means that I won't be able to use this object for currency conversion, as we need exchange rates with more than 6 decimals.The culprit is found in
ExchangeRate.cs
, line 33:Value = Math.Round(rate, 6); // value is a ratio
I've removed the rounding step in my local checkout, but this results in failing tests that involve ExchangeRates that are instantiated with the
double
data type (instead ofdecimal
). I understand why that happens and why rounding is necessary for this data type, and therefore I would like to discuss the following:double
in the first place? Especially in the Money domain, I think it would be logical to force the use ofdecimal
s when interacting with the library. I would vouch for removing this constructor.I'm very interested in hearing your opinions on this issue!
The text was updated successfully, but these errors were encountered: