The calculation precision (16) is sometimes not enough
bojanz opened this issue · comments
Bojan Zivanovic commented
Right now all amount methods use the same calculation precision:
ctx := apd.BaseContext.WithPrecision(16)
It is possible for that precision to not be enough, for example when dealing with amounts larger than a math.MaxInt64.
Discovered in #7.
A possible solution is to always use 39 digits of precision, matching decimal128, but that can impose a performance penalty for the majority use case (where 16 digits is enough), so we probably want to switch based on a.number.Coeff.IsInt64().