-
Notifications
You must be signed in to change notification settings - Fork 621
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
Sharing an optimization idea for Decimal operations #308
Comments
Nice. Does it account for overflow/underflow on addition/subtraction? What about other operations? Does it switch to using big.Int when necessary? |
I too encountered this problem. However, I utilized uint64 for storing the coefficient. Consequently, a decimal can't have more than 19 digits. It is more than enough for monetary calculations. https://github.com/govalues/decimal |
Hi @gyson, @eapenkin! :D Thanks for your amazing work and for making those libraries available to everyone. They look quite promising :D In PR #363 I've introduced a new docs section |
we use this decimal library at production and it works really well for last a few years.
The only minor complain is that some times (during profiling) we noticed that some operations are slow (e.g. sql serialization and multiplication). Most of slowness is from
big.Int
related operations. Therefore, we tried an approach to optimize (our) common cases by represent decimal numbers withint64
instead ofbig.Int
and this resulted 5x to 100x speedup.We'd like to share our result and made our approach open-sourced as well: https://github.com/alpacahq/alpacadecimal
this is to share an optimization idea that maybe works for others.
this is not an issue. be free to close it.
The text was updated successfully, but these errors were encountered: