Skip to content

Commit

Permalink
std::math::big: add the odd method to the Int structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Mar 4, 2024
1 parent 0604428 commit 8565700
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions std/math/big/int.jule
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ impl Int {
ret self.cmp(y) == 0
}

// Reports whether number is odd.
pub fn odd(self): bool {
ret self.nat.odd()
}

// Returns integer in i64.
// Causes exception if nuber large than capacity of i64.
// Exception is equals to i64.MIN constant if integer is negative, else i64.MAX.
Expand Down
5 changes: 5 additions & 0 deletions std/math/big/nat.jule
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ impl Nat {
ret bits_cmp(self.bits, y.bits) == 0
}

// Reports whether number is odd.
pub fn odd(self): bool {
ret is_odd(self.bits)
}

// Returns integer in u64.
// Causes exception if nuber large than capacity of u64.
// Exception is always equals to u64.MAX constant.
Expand Down

0 comments on commit 8565700

Please sign in to comment.