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
Seems like converting 100 units of one currency to itself will not always result in 100 units. Example:
fx.base = "USD";
fx.rates = {
"EUR" : 1.745101,
}
Result: Converting 100 EUR to EUR will actually result in 99.9999999999.
Is this something that will be fixed in the library, or do I need to figure out how to do it in my script? (I'm afraid I'm not exactly a js buff, hence the question.)
Thanks!
The text was updated successfully, but these errors were encountered:
Unless you employ something like String or github.com/dtrebbien/BigDecimal.js instead of a JavaScript number (IEEE 754 double-precision, 64 bits in total with 52 bits (=13 hex digits) for fractional part of the value), you'll have round-off. In particular when you want one cent and JavaScript stores the amount as 0.01 = (+2^-7)(1+(47ae147ae147ae1 base 16)/(16^15 - 1)), you're really storing the approximation (+2^-7)(1+(47ae147ae147a base 16)/16^13) = 0.0099999999999999984734433411404097569175064563751220703125
Seems like converting 100 units of one currency to itself will not always result in 100 units. Example:
fx.base = "USD";
fx.rates = {
"EUR" : 1.745101,
}
Result: Converting 100 EUR to EUR will actually result in 99.9999999999.
Is this something that will be fixed in the library, or do I need to figure out how to do it in my script? (I'm afraid I'm not exactly a js buff, hence the question.)
Thanks!
The text was updated successfully, but these errors were encountered: