-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add HiLo conversion method #33
Conversation
Can you elaborate why you need to convert decimal to another data type? I think libraries that has |
Example - https://github.com/tigerbeetle/tigerbeetle Currently I am using shopspring/decimal for this usecase. However, it's performance is not good, and conversion to uint128 through big.Int makes no sense as I am expecting values fit to uint128 in any case. Another example - any external storage where you also want to be able to apply a simple functions like comparison, add, etc. I.e. scaled int is ideal. But int64 is too small. And udecimal in any case targets int128, so why not allow to export to this type? Another reason is existing FromHiLo constructor. You can build udecimal from Hi/Lo pair... but you cannot deconstruct it back to Hi/Lo. |
|
done |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #33 +/- ##
==========================================
+ Coverage 96.13% 96.14% +0.01%
==========================================
Files 5 5
Lines 1863 1868 +5
==========================================
+ Hits 1791 1796 +5
Misses 48 48
Partials 24 24 ☔ View full report in Codecov by Sentry. |
Decimal type has FromHiLo constructor. The opposite method is required so the decimal type can be constructed / deconstructed. Also, ability to convert to {Hi, Lo} pair is important for integrations with other libraries which work with uint64 or uint128 types.