You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a defined a new currency (BTC with 8 digits precision) and a new Exchange Provider for the Currency.
When I try to convert 1 BTC to USD, even when the exchange rate is 5489.11, the result is 5500.
Expected Result:
The conversion should return 5489.11 USD as the value 1 BTC
Possible Solution:
Maybe I am configuring something wrong, but I think the 'roundFactor' method should use the "precision" and not the "scale" to build the MathContext. (https://docs.oracle.com/javase/8/docs/api/java/math/MathContext.html)
I think this is because the library it's using the scale and MatthContext expect the Precision.
If you use scale (in this case its 2), the factor is rounded to 5.5+e3 and that is generating the wrong value.
Case:
I have a defined a new currency (BTC with 8 digits precision) and a new Exchange Provider for the Currency.
When I try to convert 1 BTC to USD, even when the exchange rate is 5489.11, the result is 5500.
Expected Result:
The conversion should return 5489.11 USD as the value 1 BTC
Possible Solution:
Maybe I am configuring something wrong, but I think the 'roundFactor' method should use the "precision" and not the "scale" to build the MathContext. (https://docs.oracle.com/javase/8/docs/api/java/math/MathContext.html)
I think this is because the library it's using the scale and MatthContext expect the Precision.
If you use scale (in this case its 2), the factor is rounded to 5.5+e3 and that is generating the wrong value.
jsr354-ri/moneta-core/src/main/java/org/javamoney/moneta/spi/AbstractCurrencyConversion.java
Line 138 in cf8ff2b
Thanks.
The text was updated successfully, but these errors were encountered: