pub struct Integer(/* private fields */);Expand description
Arbitrary-precision integer backed by num-bigint.
§Example
use ocas_domain::Integer;
let a = Integer::from(42);
let b = Integer::new(100);
assert_eq!(a.to_string(), "42");
assert_eq!(b.to_string(), "100");Implementations§
Source§impl Integer
impl Integer
Source§impl Integer
impl Integer
Sourcepub fn modpow(&self, exp: &Integer, modulus: &Integer) -> Integer
pub fn modpow(&self, exp: &Integer, modulus: &Integer) -> Integer
Modular exponentiation: self^exp mod modulus.
Sourcepub fn mod_floor(&self, modulus: &Integer) -> Integer
pub fn mod_floor(&self, modulus: &Integer) -> Integer
Floor modulo: result r satisfies 0 ≤ r < |modulus|.
Sourcepub fn div_rem(&self, other: &Integer) -> (Integer, Integer)
pub fn div_rem(&self, other: &Integer) -> (Integer, Integer)
Division with remainder: (quotient, remainder).
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if the value is negative.
Trait Implementations§
Source§impl AddAssign<&Integer> for Integer
Available on non-crate feature gmp only.
impl AddAssign<&Integer> for Integer
Available on non-crate feature
gmp only.Source§fn add_assign(&mut self, rhs: &Integer)
fn add_assign(&mut self, rhs: &Integer)
Performs the
+= operation. Read moreSource§impl DivAssign<&Integer> for Integer
Available on non-crate feature gmp only.
impl DivAssign<&Integer> for Integer
Available on non-crate feature
gmp only.Source§fn div_assign(&mut self, rhs: &Integer)
fn div_assign(&mut self, rhs: &Integer)
Performs the
/= operation. Read moreimpl Eq for Integer
Source§impl MulAssign<&Integer> for Integer
Available on non-crate feature gmp only.
impl MulAssign<&Integer> for Integer
Available on non-crate feature
gmp only.Source§fn mul_assign(&mut self, rhs: &Integer)
fn mul_assign(&mut self, rhs: &Integer)
Performs the
*= operation. Read moreSource§impl Ord for Integer
impl Ord for Integer
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Integer
impl PartialOrd for Integer
Source§impl ShrAssign<u32> for Integer
Available on non-crate feature gmp only.
impl ShrAssign<u32> for Integer
Available on non-crate feature
gmp only.Source§fn shr_assign(&mut self, shift: u32)
fn shr_assign(&mut self, shift: u32)
Performs the
>>= operation. Read moreimpl StructuralPartialEq for Integer
Auto Trait Implementations§
impl Freeze for Integer
impl RefUnwindSafe for Integer
impl Send for Integer
impl Sync for Integer
impl Unpin for Integer
impl UnsafeUnpin for Integer
impl UnwindSafe for Integer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more