-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add additional big_math
helper functions
#1563
Conversation
WalkthroughThe updates introduce new functions to handle big integer operations in Go, including creating big integers from various integer types and performing multiplication with rounding. Additionally, new test and benchmark functions were added to ensure the correctness and performance of these operations. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- protocol/lib/big_math.go (1 hunks)
- protocol/lib/big_math_test.go (1 hunks)
Additional Context Used
Path-based Instructions (2)
protocol/lib/big_math.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.protocol/lib/big_math_test.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.
Additional comments not posted (6)
protocol/lib/big_math.go (2)
9-12
: The implementation ofBigU
is concise and correctly utilizes generics for type flexibility.
14-17
: The implementation ofBigI
is efficient and correctly handles signed integers using generics.protocol/lib/big_math_test.go (4)
31-36
: The test cases forBigI
cover a comprehensive range of scenarios, ensuring the function handles different integer sizes correctly.
38-43
: The test cases forBigU
effectively validate the function with various sizes of unsigned integers, ensuring robustness.
45-53
: The benchmark forBigMulPpm
with rounding down is correctly set up and executed, providing valuable performance insights.
55-63
: The benchmark forBigMulPpm
with rounding up is well-implemented, accurately measuring performance impacts of the rounding logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- protocol/lib/big_math.go (2 hunks)
- protocol/lib/big_math_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- protocol/lib/big_math.go
- protocol/lib/big_math_test.go
(cherry picked from commit df6794d)
Co-authored-by: Brendan Chou <[email protected]>
These changes are needed for future PRs that clean the repo of
big.Rat
Changelist
big.Int
-ify any int/uint typebig.Int
by abig.Int
ppm value (i.e. divide by1_000_000
afterwards) and round up or downbig.Int
values and return the ceiling (whereasDiv
takes the floor, andQuo
rounds towards zeroTest Plan