Skip to content

Commit

Permalink
Implement Integer::dec and inc
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed May 3, 2024
1 parent e09db4a commit 2d13702
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ name = "shootout-pidigits"
[dependencies]

[dependencies.num-integer]
version = "0.1.42"
version = "0.1.46"
default-features = false
features = ["i128"]

Expand Down
8 changes: 8 additions & 0 deletions src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ impl Integer for BigInt {
fn prev_multiple_of(&self, other: &Self) -> Self {
self - self.mod_floor(other)
}

fn dec(&mut self) {
*self -= 1u32;
}

fn inc(&mut self) {
*self += 1u32;
}
}

impl Roots for BigInt {
Expand Down
8 changes: 8 additions & 0 deletions src/biguint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ impl Integer for BigUint {
fn prev_multiple_of(&self, other: &Self) -> Self {
self - self.mod_floor(other)
}

fn dec(&mut self) {
*self -= 1u32;
}

fn inc(&mut self) {
*self += 1u32;
}
}

#[inline]
Expand Down

0 comments on commit 2d13702

Please sign in to comment.