-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b65245
commit ede2ff3
Showing
3 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign}; | ||
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not}; | ||
|
||
use crate::{ | ||
bits::{BitIteratorBE, BitIteratorLE}, | ||
|
@@ -738,6 +738,18 @@ impl<const N: usize> BitOr for BigInt<N> { | |
} | ||
} | ||
|
||
impl<const N: usize> Not for BigInt<N> { | ||
type Output = Self; | ||
|
||
fn not(self) -> Self::Output { | ||
let mut result = Self::zero(); | ||
for i in 0..N { | ||
result.0[i] = !self.0[i]; | ||
} | ||
result | ||
} | ||
} | ||
|
||
/// Compute the signed modulo operation on a u64 representation, returning the result. | ||
/// If n % modulus > modulus / 2, return modulus - n | ||
/// # Example | ||
|
@@ -800,6 +812,7 @@ pub trait BigInteger: | |
+ BitAnd<Self> | ||
+ BitOrAssign<Self> | ||
+ BitOr<Self> | ||
+ Not | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hdvanegasm
Author
Contributor
|
||
{ | ||
/// Number of 64-bit limbs representing `Self`. | ||
const NUM_LIMBS: usize; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Not here is going to be confusing -because I should perform modular operations - I don't think it needs to be in the trait definition.