pub struct CAIRO_PRIME { /* private fields */ }
Methods from Deref<Target = BigUint>§
pub const ZERO: BigUint = _
Sourcepub fn to_bytes_be(&self) -> Vec<u8> ⓘ
pub fn to_bytes_be(&self) -> Vec<u8> ⓘ
Sourcepub fn to_bytes_le(&self) -> Vec<u8> ⓘ
pub fn to_bytes_le(&self) -> Vec<u8> ⓘ
Sourcepub fn to_u32_digits(&self) -> Vec<u32>
pub fn to_u32_digits(&self) -> Vec<u32>
Returns the u32
digits representation of the BigUint
ordered least significant digit
first.
§Examples
use num_bigint::BigUint;
assert_eq!(BigUint::from(1125u32).to_u32_digits(), vec![1125]);
assert_eq!(BigUint::from(4294967295u32).to_u32_digits(), vec![4294967295]);
assert_eq!(BigUint::from(4294967296u64).to_u32_digits(), vec![0, 1]);
assert_eq!(BigUint::from(112500000000u64).to_u32_digits(), vec![830850304, 26]);
Sourcepub fn to_u64_digits(&self) -> Vec<u64>
pub fn to_u64_digits(&self) -> Vec<u64>
Returns the u64
digits representation of the BigUint
ordered least significant digit
first.
§Examples
use num_bigint::BigUint;
assert_eq!(BigUint::from(1125u32).to_u64_digits(), vec![1125]);
assert_eq!(BigUint::from(4294967295u32).to_u64_digits(), vec![4294967295]);
assert_eq!(BigUint::from(4294967296u64).to_u64_digits(), vec![4294967296]);
assert_eq!(BigUint::from(112500000000u64).to_u64_digits(), vec![112500000000]);
assert_eq!(BigUint::from(1u128 << 64).to_u64_digits(), vec![0, 1]);
Sourcepub fn iter_u32_digits(&self) -> U32Digits<'_> ⓘ
pub fn iter_u32_digits(&self) -> U32Digits<'_> ⓘ
Returns an iterator of u32
digits representation of the BigUint
ordered least
significant digit first.
§Examples
use num_bigint::BigUint;
assert_eq!(BigUint::from(1125u32).iter_u32_digits().collect::<Vec<u32>>(), vec![1125]);
assert_eq!(BigUint::from(4294967295u32).iter_u32_digits().collect::<Vec<u32>>(), vec![4294967295]);
assert_eq!(BigUint::from(4294967296u64).iter_u32_digits().collect::<Vec<u32>>(), vec![0, 1]);
assert_eq!(BigUint::from(112500000000u64).iter_u32_digits().collect::<Vec<u32>>(), vec![830850304, 26]);
Sourcepub fn iter_u64_digits(&self) -> U64Digits<'_> ⓘ
pub fn iter_u64_digits(&self) -> U64Digits<'_> ⓘ
Returns an iterator of u64
digits representation of the BigUint
ordered least
significant digit first.
§Examples
use num_bigint::BigUint;
assert_eq!(BigUint::from(1125u32).iter_u64_digits().collect::<Vec<u64>>(), vec![1125]);
assert_eq!(BigUint::from(4294967295u32).iter_u64_digits().collect::<Vec<u64>>(), vec![4294967295]);
assert_eq!(BigUint::from(4294967296u64).iter_u64_digits().collect::<Vec<u64>>(), vec![4294967296]);
assert_eq!(BigUint::from(112500000000u64).iter_u64_digits().collect::<Vec<u64>>(), vec![112500000000]);
assert_eq!(BigUint::from(1u128 << 64).iter_u64_digits().collect::<Vec<u64>>(), vec![0, 1]);
Sourcepub fn to_str_radix(&self, radix: u32) -> String
pub fn to_str_radix(&self, radix: u32) -> String
Returns the integer formatted as a string in the given radix.
radix
must be in the range 2...36
.
§Examples
use num_bigint::BigUint;
let i = BigUint::parse_bytes(b"ff", 16).unwrap();
assert_eq!(i.to_str_radix(16), "ff");
Sourcepub fn to_radix_be(&self, radix: u32) -> Vec<u8> ⓘ
pub fn to_radix_be(&self, radix: u32) -> Vec<u8> ⓘ
Returns the integer in the requested base in big-endian digit order.
The output is not given in a human readable alphabet but as a zero
based u8
number.
radix
must be in the range 2...256
.
§Examples
use num_bigint::BigUint;
assert_eq!(BigUint::from(0xFFFFu64).to_radix_be(159),
vec![2, 94, 27]);
// 0xFFFF = 65535 = 2*(159^2) + 94*159 + 27
Sourcepub fn to_radix_le(&self, radix: u32) -> Vec<u8> ⓘ
pub fn to_radix_le(&self, radix: u32) -> Vec<u8> ⓘ
Returns the integer in the requested base in little-endian digit order.
The output is not given in a human readable alphabet but as a zero
based u8 number.
radix
must be in the range 2...256
.
§Examples
use num_bigint::BigUint;
assert_eq!(BigUint::from(0xFFFFu64).to_radix_le(159),
vec![27, 94, 2]);
// 0xFFFF = 65535 = 27 + 94*159 + 2*(159^2)
Sourcepub fn modpow(&self, exponent: &BigUint, modulus: &BigUint) -> BigUint
pub fn modpow(&self, exponent: &BigUint, modulus: &BigUint) -> BigUint
Returns (self ^ exponent) % modulus
.
Panics if the modulus is zero.
Sourcepub fn modinv(&self, modulus: &BigUint) -> Option<BigUint>
pub fn modinv(&self, modulus: &BigUint) -> Option<BigUint>
Returns the modular multiplicative inverse if it exists, otherwise None
.
This solves for x
in the interval [0, modulus)
such that self * x ≡ 1 (mod modulus)
.
The solution exists if and only if gcd(self, modulus) == 1
.
use num_bigint::BigUint;
use num_traits::{One, Zero};
let m = BigUint::from(383_u32);
// Trivial cases
assert_eq!(BigUint::zero().modinv(&m), None);
assert_eq!(BigUint::one().modinv(&m), Some(BigUint::one()));
let neg1 = &m - 1u32;
assert_eq!(neg1.modinv(&m), Some(neg1));
let a = BigUint::from(271_u32);
let x = a.modinv(&m).unwrap();
assert_eq!(x, BigUint::from(106_u32));
assert_eq!(x.modinv(&m).unwrap(), a);
assert!((a * x % m).is_one());
Sourcepub fn sqrt(&self) -> BigUint
pub fn sqrt(&self) -> BigUint
Returns the truncated principal square root of self
–
see Roots::sqrt
Sourcepub fn cbrt(&self) -> BigUint
pub fn cbrt(&self) -> BigUint
Returns the truncated principal cube root of self
–
see Roots::cbrt.
Sourcepub fn nth_root(&self, n: u32) -> BigUint
pub fn nth_root(&self, n: u32) -> BigUint
Returns the truncated principal n
th root of self
–
see Roots::nth_root.
Sourcepub fn trailing_zeros(&self) -> Option<u64>
pub fn trailing_zeros(&self) -> Option<u64>
Returns the number of least-significant bits that are zero,
or None
if the entire number is zero.
Sourcepub fn trailing_ones(&self) -> u64
pub fn trailing_ones(&self) -> u64
Returns the number of least-significant bits that are ones.
Sourcepub fn count_ones(&self) -> u64
pub fn count_ones(&self) -> u64
Returns the number of one bits.
Trait Implementations§
Source§impl Deref for CAIRO_PRIME
impl Deref for CAIRO_PRIME
impl LazyStatic for CAIRO_PRIME
Auto Trait Implementations§
impl Freeze for CAIRO_PRIME
impl RefUnwindSafe for CAIRO_PRIME
impl Send for CAIRO_PRIME
impl Sync for CAIRO_PRIME
impl Unpin for CAIRO_PRIME
impl UnwindSafe for CAIRO_PRIME
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.