Skip to content

Commit

Permalink
std::math::big: fix addition and subtraction mutable data
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Mar 10, 2024
1 parent 24cd50d commit 3961790
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions std/math/big/nat.jule
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ impl Nat {

// Adds Nat.
pub fn add_assign(mut self, y: Nat) {
match {
| y.len() == 0:
if y.len() == 0 {
ret
| y.len() == 1 | self.len() >= y.len():
self.bits = clone(self.bits)
}
self.bits = clone(self.bits)
add_res(self.bits, y.bits)
}

Expand All @@ -136,12 +134,10 @@ impl Nat {

// Subtracts Nat.
pub fn sub_assign(mut self, y: Nat) {
match {
| y.len() == 0:
if y.len() == 0 {
ret
| y.len() == 1 | self.len() >= y.len():
self.bits = clone(self.bits)
}
self.bits = clone(self.bits)
sub_res(self.bits, y.bits)
self.fit()
}
Expand Down

0 comments on commit 3961790

Please sign in to comment.