Skip to content

Commit

Permalink
chore: fix safe_math
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 24, 2023
1 parent fd6dc4f commit b4ca535
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ impl SafeU120 {
b: SafeU120,
) -> SafeU120 {
let c: u120 = self.value * b.value;
assert(c / b.value == self.value);
SafeU120 {
value: c
if b.value > 0 {
// Only check if b is non-zero to not run into division by zero issues.
assert(c / b.value == self.value);
}
SafeU120 { value: c }
}

fn div(
Expand Down

0 comments on commit b4ca535

Please sign in to comment.