Skip to content

Commit

Permalink
Merge pull request #407 from DaniPopes/add-bitwise-ops
Browse files Browse the repository at this point in the history
perf: use bitwise operations in add/sub impls
  • Loading branch information
prestwich authored Dec 4, 2024
2 parents 52e4351 + 45eab6b commit b91e6f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
const fn u64_carrying_add(lhs: u64, rhs: u64, carry: bool) -> (u64, bool) {
let (a, b) = lhs.overflowing_add(rhs);
let (c, d) = a.overflowing_add(carry as u64);
(c, b || d)
(c, b | d)
}

if BITS == 0 {
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
const fn u64_borrowing_sub(lhs: u64, rhs: u64, borrow: bool) -> (u64, bool) {
let (a, b) = lhs.overflowing_sub(rhs);
let (c, d) = a.overflowing_sub(borrow as u64);
(c, b || d)
(c, b | d)
}

if BITS == 0 {
Expand Down

0 comments on commit b91e6f7

Please sign in to comment.