ManagedDecimal - mul/div half up, exp_approx, compounded_interest#2338
Merged
andrei-marinica merged 8 commits intorc/v0.66from Apr 3, 2026
Merged
ManagedDecimal - mul/div half up, exp_approx, compounded_interest#2338andrei-marinica merged 8 commits intorc/v0.66from
andrei-marinica merged 8 commits intorc/v0.66from
Conversation
|
Contract comparison - from d90dd6d to 2f40b12
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds half-up rounding arithmetic and exponential/continuous-compounding helpers to ManagedDecimal, plus scenario test coverage for the new behaviors.
Changes:
- Introduces
mul_half_up/div_half_upforManagedDecimaland signed variants with “away-from-zero” behavior. - Adds
ManagedDecimal::one,exp_approx(Taylor expansion), andcompounded_interest_factor. - Adds new scenario tests covering identity/rounding behavior and interest-factor calculations at RAY (27dp) precision.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/scenario/tests/managed_decimal_test.rs | Adds basic tests for ManagedDecimal::one and a multiplication identity check. |
| framework/scenario/tests/managed_decimal_half_up_test.rs | New integration tests for half-up rounding mul/div (unsigned + signed). |
| framework/scenario/tests/managed_decimal_compound_test.rs | New integration tests for exp_approx and compounded_interest_factor at 27 decimals. |
| framework/base/src/types/managed/wrapped/decimal/managed_decimal.rs | Adds one, exp_approx, and compounded_interest_factor implementations. |
| framework/base/src/types/managed/wrapped/decimal/managed_decimal_half_up.rs | New module implementing half-up mul/div for ManagedDecimal and ManagedDecimalSigned. |
| framework/base/src/types/managed/wrapped/decimal/decimals.rs | Makes Decimals require Clone and makes ConstDecimals::new() const fn. |
| framework/base/src/types/managed/wrapped/decimal.rs | Wires in the new managed_decimal_half_up module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
framework/base/src/types/managed/wrapped/decimal/managed_decimal.rs
Outdated
Show resolved
Hide resolved
framework/base/src/types/managed/wrapped/decimal/managed_decimal_half_up.rs
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request overview
Adds half-up rounding arithmetic and exponential/continuous-compounding helpers to
ManagedDecimal, plus scenario test coverage for the new behaviors.Changes:
mul_half_up/div_half_upforManagedDecimaland signed variants with “away-from-zero” behavior.ManagedDecimal::one,exp_approx(Taylor expansion), andcompounded_interest_factor.