Skip to content

Commit

Permalink
std::math::big: add the sign method to the Int
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Mar 12, 2024
1 parent 4361b2d commit 38566b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions std/math/big/int.jule
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@ impl Int {
ret r
}

// Returns +1 if integer is positive or zero, -1 otherwise.
pub fn sign(self): int {
if self.minus {
ret -1
}
ret +1
}

// Unary minus.
pub fn neg(self): Int {
let mut r = clone(self)
Expand Down

0 comments on commit 38566b5

Please sign in to comment.