Skip to content

Commit

Permalink
Public zeroable on i257 (#300)
Browse files Browse the repository at this point in the history
Make public Zeroable on i257 and fix is_zero for negative numbers
  • Loading branch information
gaetbout authored May 10, 2024
1 parent 22349af commit c9995a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/math/src/i257.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,17 @@ impl i257Neg of Neg<i257> {
}
}

impl i257Zeroable of Zero<i257> {
pub impl i257Zeroable of Zero<i257> {
fn zero() -> i257 {
I257Impl::new(0, false)
}
fn is_zero(self: @i257) -> bool {
assert(!*self.is_negative, 'no negative zero');
*self.abs == 0
if *self.abs == 0 {
assert(!*self.is_negative, 'no negative zero');
true
} else {
false
}
}
fn is_non_zero(self: @i257) -> bool {
!self.is_zero()
Expand Down

0 comments on commit c9995a4

Please sign in to comment.