-
Notifications
You must be signed in to change notification settings - Fork 40
Power function #505
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
base: main
Are you sure you want to change the base?
Power function #505
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #505 +/- ##
==========================================
+ Coverage 95.02% 95.06% +0.03%
==========================================
Files 77 77
Lines 5309 5408 +99
==========================================
+ Hits 5045 5141 +96
- Misses 264 267 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
brozorec
left a comment
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.
great job with the re-org 🙌 just couple of nit picks and improving the coverage for checked_mul_div_floor
| /// `WAD_SCALE`. | ||
| pub fn checked_mul(self, e: &Env, rhs: Wad) -> Option<Wad> { | ||
| // Use fixed_mul_floor to handle phantom overflow transparently | ||
| let result = self.0.fixed_mul_floor(e, &rhs.0, &WAD_SCALE); |
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.
Shouldn't we use checked_fixed_mul_floor so that it returns None instead of panicking on overflow?
| } | ||
| } | ||
|
|
||
| /// Performs floor(x * y / z) |
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.
| /// Performs ceil(x * y / z) |
| let zero = I256::from_i32(env, 0); | ||
| let r = x.mul(y); | ||
|
|
||
| if z.clone() == zero { |
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.
instead of cloning, wouldn't it be better to dereference z here and in the next fn?
Fixes #499
PR Checklist
Also restructures the math library