-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix: RelativePow now returns 1 when 0^0 #18211
Conversation
WalkthroughThis pull request addresses two key bug fixes in the Changes
TipsChat with CodeRabbit Bot (
|
This comment has been minimized.
This comment has been minimized.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- math/uint.go (1 hunks)
- math/uint_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
- math/uint.go
Additional comments (Suppressed): 1
math/uint_test.go (1)
- 274-274: The test case has been updated to reflect the new expected behavior of the
RelativePow
function when bothx
andn
are zero. The expected result has been changed fromsdkmath.NewUint(10)
tosdkmath.NewUint(1)
, which is the correct mathematical result for0^0
. This change is consistent with the updated implementation of theRelativePow
function.
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.
dont think we can backport this to 0.47 but 0.50 is safe |
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.
Agree with Marko that we shouldn't backport to v0.47.
(cherry picked from commit 442c3c5) # Conflicts: # math/CHANGELOG.md # math/uint.go
I forgot this is math. So this is the same version used in v0.47, v0.50, etc.. this means the backported wasn't necessary and that it will be in v0.47 available. @facundomedica can you check on source graph that no one depends on it? Otherwise I'll check myself once im no more afk. |
Description
I've checked current usages and it doesn't look like there are people misusing this enough to ever get the wrong result. The issue is that when x and n are 0 then the result is whatever being passed as b, even though there's a comment stating
// 0^0 = 1
.This is not being used in the SDK btw.
https://github.com/search?q=RelativePow+language%3AGo&type=code&l=Go
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
RelativePow
function to return 1 when raising 0 to the power of 0, enhancing the mathematical accuracy of the software.ApproxRoot
function's rounding behavior, ensuring consistent and expected results across all calculations.These changes improve the reliability of mathematical operations within the software, providing users with more accurate and predictable results.