-
Notifications
You must be signed in to change notification settings - Fork 602
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(osmomath): mutative and efficient BigDec truncations with arbitrary decimals #6257
Comments
hey @p0mvn. I have a question on this: wdym mutative and non-mutative versions? do you mean |
Hey. For reference, please see The benefit of the mutative version is that it doesn't reallocate and mutates the receiver directly. However, it cannot be used always. As a result, we need two versions for most math methods |
in cases of mutative we could set the underlying cc: @p0mvn |
To make the mutative There should be a warning made that it makes the original |
Background
Currently, our
SDKDec()
method ofBigDec
does a lot of reallocations. Additionally, this function only truncates tosdk.Dec
with precision of 18.Suggested Design
We should have a way to truncate an arbitrary number of digits. The number of reallocations should be minimized. Mutative and non-mutative versions should be implemented.
See
chopPrecisionAndTruncate
function for reference. Also, see howchopPrecisionAndRoundUpNonMutative
andchopPrecisionAndRoundUp
are implemented. Clean up and enhance abstractions where applicable.Acceptance Criteria
SDKDec()
to utilize these new functions to minimize reallocations while preserving state-compatibility.The text was updated successfully, but these errors were encountered: