Struct num_bigint::BigUint [−][src]
pub struct BigUint { /* fields omitted */ }A big unsigned integer type.
Implementations
impl BigUint[src]
impl BigUint[src]pub fn new(digits: Vec<u32>) -> BigUint[src]
Creates and initializes a BigUint.
The base 232 digits are ordered least significant digit first.
pub fn from_slice(slice: &[u32]) -> BigUint[src]
Creates and initializes a BigUint.
The base 232 digits are ordered least significant digit first.
pub fn assign_from_slice(&mut self, slice: &[u32])[src]
Assign a value to a BigUint.
The base 232 digits are ordered least significant digit first.
pub fn from_bytes_be(bytes: &[u8]) -> BigUint[src]
Creates and initializes a BigUint.
The bytes are in big-endian byte order.
Examples
use num_bigint::BigUint; assert_eq!(BigUint::from_bytes_be(b"A"), BigUint::parse_bytes(b"65", 10).unwrap()); assert_eq!(BigUint::from_bytes_be(b"AA"), BigUint::parse_bytes(b"16705", 10).unwrap()); assert_eq!(BigUint::from_bytes_be(b"AB"), BigUint::parse_bytes(b"16706", 10).unwrap()); assert_eq!(BigUint::from_bytes_be(b"Hello world!"), BigUint::parse_bytes(b"22405534230753963835153736737", 10).unwrap());
pub fn from_bytes_le(bytes: &[u8]) -> BigUint[src]
Creates and initializes a BigUint.
The bytes are in little-endian byte order.
pub fn parse_bytes(buf: &[u8], radix: u32) -> Option<BigUint>[src]
Creates and initializes a BigUint. The input slice must contain
ascii/utf8 characters in [0-9a-zA-Z].
radix must be in the range 2...36.
The function from_str_radix from the Num trait provides the same logic
for &str buffers.
Examples
use num_bigint::{BigUint, ToBigUint}; assert_eq!(BigUint::parse_bytes(b"1234", 10), ToBigUint::to_biguint(&1234)); assert_eq!(BigUint::parse_bytes(b"ABCD", 16), ToBigUint::to_biguint(&0xABCD)); assert_eq!(BigUint::parse_bytes(b"G", 16), None);
pub fn from_radix_be(buf: &[u8], radix: u32) -> Option<BigUint>[src]
Creates and initializes a BigUint. Each u8 of the input slice is
interpreted as one digit of the number
and must therefore be less than radix.
The bytes are in big-endian byte order.
radix must be in the range 2...256.
Examples
use num_bigint::{BigUint}; let inbase190 = &[15, 33, 125, 12, 14]; let a = BigUint::from_radix_be(inbase190, 190).unwrap(); assert_eq!(a.to_radix_be(190), inbase190);
pub fn from_radix_le(buf: &[u8], radix: u32) -> Option<BigUint>[src]
Creates and initializes a BigUint. Each u8 of the input slice is
interpreted as one digit of the number
and must therefore be less than radix.
The bytes are in little-endian byte order.
radix must be in the range 2...256.
Examples
use num_bigint::{BigUint}; let inbase190 = &[14, 12, 125, 33, 15]; let a = BigUint::from_radix_be(inbase190, 190).unwrap(); assert_eq!(a.to_radix_be(190), inbase190);
pub fn to_bytes_be(&self) -> Vec<u8>[src]
Returns the byte representation of the BigUint in big-endian byte order.
Examples
use num_bigint::BigUint; let i = BigUint::parse_bytes(b"1125", 10).unwrap(); assert_eq!(i.to_bytes_be(), vec![4, 101]);
pub fn to_bytes_le(&self) -> Vec<u8>[src]
Returns the byte representation of the BigUint in little-endian byte order.
Examples
use num_bigint::BigUint; let i = BigUint::parse_bytes(b"1125", 10).unwrap(); assert_eq!(i.to_bytes_le(), vec![101, 4]);
pub fn to_u32_digits(&self) -> Vec<u32>[src]
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]);
pub fn to_str_radix(&self, radix: u32) -> String[src]
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");
pub fn to_radix_be(&self, radix: u32) -> Vec<u8>[src]
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
pub fn to_radix_le(&self, radix: u32) -> Vec<u8>[src]
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)
pub fn bits(&self) -> usize[src]
Determines the fewest bits necessary to express the BigUint.
pub fn modpow(&self, exponent: &Self, modulus: &Self) -> Self[src]
Returns (self ^ exponent) % modulus.
Panics if the modulus is zero.
pub fn sqrt(&self) -> Self[src]
Returns the truncated principal square root of self –
see Roots::sqrt
pub fn cbrt(&self) -> Self[src]
Returns the truncated principal cube root of self –
see Roots::cbrt.
pub fn nth_root(&self, n: u32) -> Self[src]
Returns the truncated principal nth root of self –
see Roots::nth_root.
Trait Implementations
impl<'a> BitAndAssign<&'a BigUint> for BigUint[src]
impl<'a> BitAndAssign<&'a BigUint> for BigUint[src]fn bitand_assign(&mut self, other: &BigUint)[src]
impl BitAndAssign<BigUint> for BigUint[src]
impl BitAndAssign<BigUint> for BigUint[src]fn bitand_assign(&mut self, other: BigUint)[src]
impl<'a> BitOrAssign<&'a BigUint> for BigUint[src]
impl<'a> BitOrAssign<&'a BigUint> for BigUint[src]fn bitor_assign(&mut self, other: &BigUint)[src]
impl BitOrAssign<BigUint> for BigUint[src]
impl BitOrAssign<BigUint> for BigUint[src]fn bitor_assign(&mut self, other: BigUint)[src]
impl<'a> BitXorAssign<&'a BigUint> for BigUint[src]
impl<'a> BitXorAssign<&'a BigUint> for BigUint[src]fn bitxor_assign(&mut self, other: &BigUint)[src]
impl BitXorAssign<BigUint> for BigUint[src]
impl BitXorAssign<BigUint> for BigUint[src]fn bitxor_assign(&mut self, other: BigUint)[src]
impl CheckedAdd for BigUint[src]
impl CheckedAdd for BigUint[src]fn checked_add(&self, v: &BigUint) -> Option<BigUint>[src]
impl CheckedDiv for BigUint[src]
impl CheckedDiv for BigUint[src]fn checked_div(&self, v: &BigUint) -> Option<BigUint>[src]
impl CheckedMul for BigUint[src]
impl CheckedMul for BigUint[src]fn checked_mul(&self, v: &BigUint) -> Option<BigUint>[src]
impl CheckedSub for BigUint[src]
impl CheckedSub for BigUint[src]fn checked_sub(&self, v: &BigUint) -> Option<BigUint>[src]
impl FromPrimitive for BigUint[src]
impl FromPrimitive for BigUint[src]fn from_i64(n: i64) -> Option<BigUint>[src]
fn from_i128(n: i128) -> Option<BigUint>[src]
fn from_u64(n: u64) -> Option<BigUint>[src]
fn from_u128(n: u128) -> Option<BigUint>[src]
fn from_f64(n: f64) -> Option<BigUint>[src]
pub fn from_isize(n: isize) -> Option<Self>[src]
pub fn from_i8(n: i8) -> Option<Self>[src]
pub fn from_i16(n: i16) -> Option<Self>[src]
pub fn from_i32(n: i32) -> Option<Self>[src]
pub fn from_usize(n: usize) -> Option<Self>[src]
pub fn from_u8(n: u8) -> Option<Self>[src]
pub fn from_u16(n: u16) -> Option<Self>[src]
pub fn from_u32(n: u32) -> Option<Self>[src]
pub fn from_f32(n: f32) -> Option<Self>[src]
impl FromStr for BigUint[src]
impl FromStr for BigUint[src]type Err = ParseBigIntError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<BigUint, ParseBigIntError>[src]
impl Integer for BigUint[src]
impl Integer for BigUint[src]fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint)[src]
fn div_floor(&self, other: &BigUint) -> BigUint[src]
fn mod_floor(&self, other: &BigUint) -> BigUint[src]
fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint)[src]
fn gcd(&self, other: &Self) -> Self[src]
Calculates the Greatest Common Divisor (GCD) of the number and other.
The result is always positive.
fn lcm(&self, other: &BigUint) -> BigUint[src]
Calculates the Lowest Common Multiple (LCM) of the number and other.
fn divides(&self, other: &BigUint) -> bool[src]
Deprecated, use is_multiple_of instead.
fn is_multiple_of(&self, other: &BigUint) -> bool[src]
Returns true if the number is a multiple of other.
fn is_even(&self) -> bool[src]
Returns true if the number is divisible by 2.
fn is_odd(&self) -> bool[src]
Returns true if the number is not divisible by 2.
pub fn div_ceil(&self, other: &Self) -> Self[src]
pub fn gcd_lcm(&self, other: &Self) -> (Self, Self)[src]
pub fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self> where
Self: Clone, [src]
Self: Clone,
pub fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self) where
Self: Clone + Signed, [src]
Self: Clone + Signed,
pub fn next_multiple_of(&self, other: &Self) -> Self where
Self: Clone, [src]
Self: Clone,
pub fn prev_multiple_of(&self, other: &Self) -> Self where
Self: Clone, [src]
Self: Clone,
impl Num for BigUint[src]
impl Num for BigUint[src]type FromStrRadixErr = ParseBigIntError
fn from_str_radix(s: &str, radix: u32) -> Result<BigUint, ParseBigIntError>[src]
Creates and initializes a BigUint.
impl PartialOrd<BigUint> for BigUint[src]
impl PartialOrd<BigUint> for BigUint[src]impl ToPrimitive for BigUint[src]
impl ToPrimitive for BigUint[src]fn to_i64(&self) -> Option<i64>[src]
fn to_i128(&self) -> Option<i128>[src]
fn to_u64(&self) -> Option<u64>[src]
fn to_u128(&self) -> Option<u128>[src]
fn to_f32(&self) -> Option<f32>[src]
fn to_f64(&self) -> Option<f64>[src]
pub fn to_isize(&self) -> Option<isize>[src]
pub fn to_i8(&self) -> Option<i8>[src]
pub fn to_i16(&self) -> Option<i16>[src]
pub fn to_i32(&self) -> Option<i32>[src]
pub fn to_usize(&self) -> Option<usize>[src]
pub fn to_u8(&self) -> Option<u8>[src]
pub fn to_u16(&self) -> Option<u16>[src]
pub fn to_u32(&self) -> Option<u32>[src]
impl Eq for BigUint[src]
impl Unsigned for BigUint[src]
Auto Trait Implementations
impl RefUnwindSafe for BigUint
impl Send for BigUint
impl Sync for BigUint
impl Unpin for BigUint
impl UnwindSafe for BigUint
Blanket Implementations
impl<I> Average for I where
I: Integer + Shr<usize, Output = I>,
&'a I: for<'a, 'b> BitAnd<&'b I>,
&'a I: for<'a, 'b> BitOr<&'b I>,
&'a I: for<'a, 'b> BitXor<&'b I>,
<&'a I as BitAnd<&'b I>>::Output == I,
<&'a I as BitOr<&'b I>>::Output == I,
<&'a I as BitXor<&'b I>>::Output == I, [src]
impl<I> Average for I where
I: Integer + Shr<usize, Output = I>,
&'a I: for<'a, 'b> BitAnd<&'b I>,
&'a I: for<'a, 'b> BitOr<&'b I>,
&'a I: for<'a, 'b> BitXor<&'b I>,
<&'a I as BitAnd<&'b I>>::Output == I,
<&'a I as BitOr<&'b I>>::Output == I,
<&'a I as BitXor<&'b I>>::Output == I, [src]pub fn average_floor(&self, other: &I) -> I[src]
Returns the floor value of the average of self and other.
pub fn average_ceil(&self, other: &I) -> I[src]
Returns the ceil value of the average of self and other.
impl<T> NumAssign for T where
T: Num + NumAssignOps<T>, [src]
T: Num + NumAssignOps<T>,
impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, [src]
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
impl<T> NumAssignRef for T where
T: NumAssign + for<'r> NumAssignOps<&'r T>, [src]
T: NumAssign + for<'r> NumAssignOps<&'r T>,
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, [src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T> NumRef for T where
T: Num + for<'r> NumOps<&'r T, T>, [src]
T: Num + for<'r> NumOps<&'r T, T>,
impl<T, Base> RefNum<Base> for T where
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>, [src]
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,