// `Add`/`Sub` ops may flip from `BigInt` to its `BigUint` magnitude #![allow(clippy::suspicious_arithmetic_impl)]
use alloc::string::String; use alloc::vec::Vec; use core::cmp::Ordering::{self, Equal}; use core::default::Default; use core::fmt; use core::hash; use core::ops::{Neg, Not}; use core::str;
use num_integer::{Integer, Roots}; use num_traits::{ConstZero, Num, One, Pow, Signed, Zero};
impl Integer for BigInt { #[inline] fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) { // r.sign == self.sign let (d_ui, r_ui) = self.data.div_rem(&other.data); let d = BigInt::from_biguint(self.sign, d_ui); let r = BigInt::from_biguint(self.sign, r_ui); if other.is_negative() {
(-d, r)
} else {
(d, r)
}
}
#[inline] fn div_floor(&self, other: &BigInt) -> BigInt { let (d_ui, m) = self.data.div_mod_floor(&other.data); let d = BigInt::from(d_ui); match (self.sign, other.sign) {
(Plus, Plus) | (NoSign, Plus) | (Minus, Minus) => d,
(Plus, Minus) | (NoSign, Minus) | (Minus, Plus) => { if m.is_zero() {
-d
} else {
-d - 1u32
}
}
(_, NoSign) => unreachable!(),
}
}
#[inline] fn mod_floor(&self, other: &BigInt) -> BigInt { // m.sign == other.sign let m_ui = self.data.mod_floor(&other.data); let m = BigInt::from_biguint(other.sign, m_ui); match (self.sign, other.sign) {
(Plus, Plus) | (NoSign, Plus) | (Minus, Minus) => m,
(Plus, Minus) | (NoSign, Minus) | (Minus, Plus) => { if m.is_zero() {
m
} else {
other - m
}
}
(_, NoSign) => unreachable!(),
}
}
fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt) { // m.sign == other.sign let (d_ui, m_ui) = self.data.div_mod_floor(&other.data); let d = BigInt::from(d_ui); let m = BigInt::from_biguint(other.sign, m_ui); match (self.sign, other.sign) {
(Plus, Plus) | (NoSign, Plus) | (Minus, Minus) => (d, m),
(Plus, Minus) | (NoSign, Minus) | (Minus, Plus) => { if m.is_zero() {
(-d, m)
} else {
(-d - 1u32, other - m)
}
}
(_, NoSign) => unreachable!(),
}
}
#[inline] fn div_ceil(&self, other: &Self) -> Self { let (d_ui, m) = self.data.div_mod_floor(&other.data); let d = BigInt::from(d_ui); match (self.sign, other.sign) {
(Plus, Minus) | (NoSign, Minus) | (Minus, Plus) => -d,
(Plus, Plus) | (NoSign, Plus) | (Minus, Minus) => { if m.is_zero() {
d
} else {
d + 1u32
}
}
(_, NoSign) => unreachable!(),
}
}
/// Calculates the Greatest Common Divisor (GCD) of the number and `other`. /// /// The result is always positive. #[inline] fn gcd(&self, other: &BigInt) -> BigInt {
BigInt::from(self.data.gcd(&other.data))
}
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`. #[inline] fn lcm(&self, other: &BigInt) -> BigInt {
BigInt::from(self.data.lcm(&other.data))
}
/// Calculates the Greatest Common Divisor (GCD) and /// Lowest Common Multiple (LCM) together. #[inline] fn gcd_lcm(&self, other: &BigInt) -> (BigInt, BigInt) { let (gcd, lcm) = self.data.gcd_lcm(&other.data);
(BigInt::from(gcd), BigInt::from(lcm))
}
/// Greatest common divisor, least common multiple, and Bézout coefficients. #[inline] fn extended_gcd_lcm(&self, other: &BigInt) -> (num_integer::ExtendedGcd<BigInt>, BigInt) { let egcd = self.extended_gcd(other); let lcm = if egcd.gcd.is_zero() { Self::ZERO
} else {
BigInt::from(&self.data / &egcd.gcd.data * &other.data)
};
(egcd, lcm)
}
/// Returns `true` if the number is a multiple of `other`. #[inline] fn is_multiple_of(&self, other: &BigInt) -> bool { self.data.is_multiple_of(&other.data)
}
/// Returns `true` if the number is divisible by `2`. #[inline] fn is_even(&self) -> bool { self.data.is_even()
}
/// Returns `true` if the number is not divisible by `2`. #[inline] fn is_odd(&self) -> bool { self.data.is_odd()
}
/// Rounds up to nearest multiple of argument. #[inline] fn next_multiple_of(&self, other: &Self) -> Self { let m = self.mod_floor(other); if m.is_zero() { self.clone()
} else { self + (other - m)
}
} /// Rounds down to nearest multiple of argument. #[inline] fn prev_multiple_of(&self, other: &Self) -> Self { self - self.mod_floor(other)
}
fn dec(&mutself) {
*self -= 1u32;
}
fn inc(&mutself) {
*self += 1u32;
}
}
impl Roots for BigInt { fn nth_root(&self, n: u32) -> Self {
assert!(
!(self.is_negative() && n.is_even()), "root of degree {} is imaginary",
n
);
/// A generic trait for converting a value to a [`BigInt`]. This may return /// `None` when converting from `f32` or `f64`, and will always succeed /// when converting from any integer or unsigned primitive, or [`BigUint`]. pubtrait ToBigInt { /// Converts the value of `self` to a [`BigInt`]. fn to_bigint(&self) -> Option<BigInt>;
}
impl BigInt { /// A constant `BigInt` with value 0, useful for static initialization. pubconst ZERO: Self = BigInt {
sign: NoSign,
data: BigUint::ZERO,
};
/// Creates and initializes a [`BigInt`]. /// /// The base 2<sup>32</sup> digits are ordered least significant digit first. #[inline] pubfn new(sign: Sign, digits: Vec<u32>) -> BigInt {
BigInt::from_biguint(sign, BigUint::new(digits))
}
/// Creates and initializes a [`BigInt`]. /// /// The base 2<sup>32</sup> digits are ordered least significant digit first. #[inline] pubfn from_biguint(mut sign: Sign, mut data: BigUint) -> BigInt { if sign == NoSign {
data.assign_from_slice(&[]);
} elseif data.is_zero() {
sign = NoSign;
}
BigInt { sign, data }
}
/// Creates and initializes a [`BigInt`]. /// /// The base 2<sup>32</sup> digits are ordered least significant digit first. #[inline] pubfn from_slice(sign: Sign, slice: &[u32]) -> BigInt {
BigInt::from_biguint(sign, BigUint::from_slice(slice))
}
/// Reinitializes a [`BigInt`]. /// /// The base 2<sup>32</sup> digits are ordered least significant digit first. #[inline] pubfn assign_from_slice(&mutself, sign: Sign, slice: &[u32]) { if sign == NoSign { self.set_zero();
} else { self.data.assign_from_slice(slice); self.sign = ifself.data.is_zero() { NoSign } else { sign };
}
}
/// Creates and initializes a [`BigInt`]. /// /// The bytes are in little-endian byte order. #[inline] pubfn from_bytes_le(sign: Sign, bytes: &[u8]) -> BigInt {
BigInt::from_biguint(sign, BigUint::from_bytes_le(bytes))
}
/// Creates and initializes a [`BigInt`] from an array of bytes in /// two's complement binary representation. /// /// The digits are in big-endian base 2<sup>8</sup>. #[inline] pubfn from_signed_bytes_be(digits: &[u8]) -> BigInt {
convert::from_signed_bytes_be(digits)
}
/// Creates and initializes a [`BigInt`] from an array of bytes in two's complement. /// /// The digits are in little-endian base 2<sup>8</sup>. #[inline] pubfn from_signed_bytes_le(digits: &[u8]) -> BigInt {
convert::from_signed_bytes_le(digits)
}
/// Creates and initializes a [`BigInt`]. /// /// # Examples /// /// ``` /// use num_bigint::{BigInt, ToBigInt}; /// /// assert_eq!(BigInt::parse_bytes(b"1234", 10), ToBigInt::to_bigint(&1234)); /// assert_eq!(BigInt::parse_bytes(b"ABCD", 16), ToBigInt::to_bigint(&0xABCD)); /// assert_eq!(BigInt::parse_bytes(b"G", 16), None); /// ``` #[inline] pubfn parse_bytes(buf: &[u8], radix: u32) -> Option<BigInt> { let s = str::from_utf8(buf).ok()?;
BigInt::from_str_radix(s, radix).ok()
}
/// Creates and initializes a [`BigInt`]. 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::{BigInt, Sign}; /// /// let inbase190 = vec![15, 33, 125, 12, 14]; /// let a = BigInt::from_radix_be(Sign::Minus, &inbase190, 190).unwrap(); /// assert_eq!(a.to_radix_be(190), (Sign:: Minus, inbase190)); /// ``` pubfn from_radix_be(sign: Sign, buf: &[u8], radix: u32) -> Option<BigInt> { let u = BigUint::from_radix_be(buf, radix)?;
Some(BigInt::from_biguint(sign, u))
}
/// Creates and initializes a [`BigInt`]. 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::{BigInt, Sign}; /// /// let inbase190 = vec![14, 12, 125, 33, 15]; /// let a = BigInt::from_radix_be(Sign::Minus, &inbase190, 190).unwrap(); /// assert_eq!(a.to_radix_be(190), (Sign::Minus, inbase190)); /// ``` pubfn from_radix_le(sign: Sign, buf: &[u8], radix: u32) -> Option<BigInt> { let u = BigUint::from_radix_le(buf, radix)?;
Some(BigInt::from_biguint(sign, u))
}
/// Returns the sign and the byte representation of the [`BigInt`] in big-endian byte order. /// /// # Examples /// /// ``` /// use num_bigint::{ToBigInt, Sign}; /// /// let i = -1125.to_bigint().unwrap(); /// assert_eq!(i.to_bytes_be(), (Sign::Minus, vec![4, 101])); /// ``` #[inline] pubfn to_bytes_be(&self) -> (Sign, Vec<u8>) {
(self.sign, self.data.to_bytes_be())
}
/// Returns the sign and the byte representation of the [`BigInt`] in little-endian byte order. /// /// # Examples /// /// ``` /// use num_bigint::{ToBigInt, Sign}; /// /// let i = -1125.to_bigint().unwrap(); /// assert_eq!(i.to_bytes_le(), (Sign::Minus, vec![101, 4])); /// ``` #[inline] pubfn to_bytes_le(&self) -> (Sign, Vec<u8>) {
(self.sign, self.data.to_bytes_le())
}
/// Returns the sign and the `u32` digits representation of the [`BigInt`] ordered least /// significant digit first. /// /// # Examples /// /// ``` /// use num_bigint::{BigInt, Sign}; /// /// assert_eq!(BigInt::from(-1125).to_u32_digits(), (Sign::Minus, vec![1125])); /// assert_eq!(BigInt::from(4294967295u32).to_u32_digits(), (Sign::Plus, vec![4294967295])); /// assert_eq!(BigInt::from(4294967296u64).to_u32_digits(), (Sign::Plus, vec![0, 1])); /// assert_eq!(BigInt::from(-112500000000i64).to_u32_digits(), (Sign::Minus, vec![830850304, 26])); /// assert_eq!(BigInt::from(112500000000i64).to_u32_digits(), (Sign::Plus, vec![830850304, 26])); /// ``` #[inline] pubfn to_u32_digits(&self) -> (Sign, Vec<u32>) {
(self.sign, self.data.to_u32_digits())
}
/// Returns the sign and the `u64` digits representation of the [`BigInt`] ordered least /// significant digit first. /// /// # Examples /// /// ``` /// use num_bigint::{BigInt, Sign}; /// /// assert_eq!(BigInt::from(-1125).to_u64_digits(), (Sign::Minus, vec![1125])); /// assert_eq!(BigInt::from(4294967295u32).to_u64_digits(), (Sign::Plus, vec![4294967295])); /// assert_eq!(BigInt::from(4294967296u64).to_u64_digits(), (Sign::Plus, vec![4294967296])); /// assert_eq!(BigInt::from(-112500000000i64).to_u64_digits(), (Sign::Minus, vec![112500000000])); /// assert_eq!(BigInt::from(112500000000i64).to_u64_digits(), (Sign::Plus, vec![112500000000])); /// assert_eq!(BigInt::from(1u128 << 64).to_u64_digits(), (Sign::Plus, vec![0, 1])); /// ``` #[inline] pubfn to_u64_digits(&self) -> (Sign, Vec<u64>) {
(self.sign, self.data.to_u64_digits())
}
/// Returns an iterator of `u32` digits representation of the [`BigInt`] ordered least /// significant digit first. /// /// # Examples /// /// ``` /// use num_bigint::BigInt; /// /// assert_eq!(BigInt::from(-1125).iter_u32_digits().collect::<Vec<u32>>(), vec![1125]); /// assert_eq!(BigInt::from(4294967295u32).iter_u32_digits().collect::<Vec<u32>>(), vec![4294967295]); /// assert_eq!(BigInt::from(4294967296u64).iter_u32_digits().collect::<Vec<u32>>(), vec![0, 1]); /// assert_eq!(BigInt::from(-112500000000i64).iter_u32_digits().collect::<Vec<u32>>(), vec![830850304, 26]); /// assert_eq!(BigInt::from(112500000000i64).iter_u32_digits().collect::<Vec<u32>>(), vec![830850304, 26]); /// ``` #[inline] pubfn iter_u32_digits(&self) -> U32Digits<'_> { self.data.iter_u32_digits()
}
/// Returns an iterator of `u64` digits representation of the [`BigInt`] ordered least /// significant digit first. /// /// # Examples /// /// ``` /// use num_bigint::BigInt; /// /// assert_eq!(BigInt::from(-1125).iter_u64_digits().collect::<Vec<u64>>(), vec![1125u64]); /// assert_eq!(BigInt::from(4294967295u32).iter_u64_digits().collect::<Vec<u64>>(), vec![4294967295u64]); /// assert_eq!(BigInt::from(4294967296u64).iter_u64_digits().collect::<Vec<u64>>(), vec![4294967296u64]); /// assert_eq!(BigInt::from(-112500000000i64).iter_u64_digits().collect::<Vec<u64>>(), vec![112500000000u64]); /// assert_eq!(BigInt::from(112500000000i64).iter_u64_digits().collect::<Vec<u64>>(), vec![112500000000u64]); /// assert_eq!(BigInt::from(1u128 << 64).iter_u64_digits().collect::<Vec<u64>>(), vec![0, 1]); /// ``` #[inline] pubfn iter_u64_digits(&self) -> U64Digits<'_> { self.data.iter_u64_digits()
}
/// Returns the two's-complement byte representation of the [`BigInt`] in big-endian byte order. /// /// # Examples /// /// ``` /// use num_bigint::ToBigInt; /// /// let i = -1125.to_bigint().unwrap(); /// assert_eq!(i.to_signed_bytes_be(), vec![251, 155]); /// ``` #[inline] pubfn to_signed_bytes_be(&self) -> Vec<u8> {
convert::to_signed_bytes_be(self)
}
/// Returns the two's-complement byte representation of the [`BigInt`] in little-endian byte order. /// /// # Examples /// /// ``` /// use num_bigint::ToBigInt; /// /// let i = -1125.to_bigint().unwrap(); /// assert_eq!(i.to_signed_bytes_le(), vec![155, 251]); /// ``` #[inline] pubfn to_signed_bytes_le(&self) -> Vec<u8> {
convert::to_signed_bytes_le(self)
}
/// Returns the integer formatted as a string in the given radix. /// `radix` must be in the range `2...36`. /// /// # Examples /// /// ``` /// use num_bigint::BigInt; /// /// let i = BigInt::parse_bytes(b"ff", 16).unwrap(); /// assert_eq!(i.to_str_radix(16), "ff"); /// ``` #[inline] pubfn to_str_radix(&self, radix: u32) -> String { letmut v = to_str_radix_reversed(&self.data, radix);
/// 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::{BigInt, Sign}; /// /// assert_eq!(BigInt::from(-0xFFFFi64).to_radix_be(159), /// (Sign::Minus, vec![2, 94, 27])); /// // 0xFFFF = 65535 = 2*(159^2) + 94*159 + 27 /// ``` #[inline] pubfn to_radix_be(&self, radix: u32) -> (Sign, Vec<u8>) {
(self.sign, self.data.to_radix_be(radix))
}
/// 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::{BigInt, Sign}; /// /// assert_eq!(BigInt::from(-0xFFFFi64).to_radix_le(159), /// (Sign::Minus, vec![27, 94, 2])); /// // 0xFFFF = 65535 = 27 + 94*159 + 2*(159^2) /// ``` #[inline] pubfn to_radix_le(&self, radix: u32) -> (Sign, Vec<u8>) {
(self.sign, self.data.to_radix_le(radix))
}
/// Returns the sign of the [`BigInt`] as a [`Sign`]. /// /// # Examples /// /// ``` /// use num_bigint::{BigInt, Sign}; /// /// assert_eq!(BigInt::from(1234).sign(), Sign::Plus); /// assert_eq!(BigInt::from(-4321).sign(), Sign::Minus); /// assert_eq!(BigInt::ZERO.sign(), Sign::NoSign); /// ``` #[inline] pubfn sign(&self) -> Sign { self.sign
}
/// Returns the magnitude of the [`BigInt`] as a [`BigUint`]. /// /// # Examples /// /// ``` /// use num_bigint::{BigInt, BigUint}; /// use num_traits::Zero; /// /// assert_eq!(BigInt::from(1234).magnitude(), &BigUint::from(1234u32)); /// assert_eq!(BigInt::from(-4321).magnitude(), &BigUint::from(4321u32)); /// assert!(BigInt::ZERO.magnitude().is_zero()); /// ``` #[inline] pubfn magnitude(&self) -> &BigUint {
&self.data
}
/// Convert this [`BigInt`] into its [`Sign`] and [`BigUint`] magnitude, /// the reverse of [`BigInt::from_biguint()`]. /// /// # Examples /// /// ``` /// use num_bigint::{BigInt, BigUint, Sign}; /// /// assert_eq!(BigInt::from(1234).into_parts(), (Sign::Plus, BigUint::from(1234u32))); /// assert_eq!(BigInt::from(-4321).into_parts(), (Sign::Minus, BigUint::from(4321u32))); /// assert_eq!(BigInt::ZERO.into_parts(), (Sign::NoSign, BigUint::ZERO)); /// ``` #[inline] pubfn into_parts(self) -> (Sign, BigUint) {
(self.sign, self.data)
}
/// Determines the fewest bits necessary to express the [`BigInt`], /// not including the sign. #[inline] pubfn bits(&self) -> u64 { self.data.bits()
}
/// Converts this [`BigInt`] into a [`BigUint`], if it's not negative. #[inline] pubfn to_biguint(&self) -> Option<BigUint> { matchself.sign {
Plus => Some(self.data.clone()),
NoSign => Some(BigUint::ZERO),
Minus => None,
}
}
/// Returns `(self ^ exponent) mod modulus` /// /// Note that this rounds like `mod_floor`, not like the `%` operator, /// which makes a difference when given a negative `self` or `modulus`. /// The result will be in the interval `[0, modulus)` for `modulus > 0`, /// or in the interval `(modulus, 0]` for `modulus < 0` /// /// Panics if the exponent is negative or the modulus is zero. pubfn modpow(&self, exponent: &Self, modulus: &Self) -> Self {
power::modpow(self, exponent, modulus)
}
/// Returns the modular multiplicative inverse if it exists, otherwise `None`. /// /// This solves for `x` such that `self * x ≡ 1 (mod modulus)`. /// Note that this rounds like `mod_floor`, not like the `%` operator, /// which makes a difference when given a negative `self` or `modulus`. /// The solution will be in the interval `[0, modulus)` for `modulus > 0`, /// or in the interval `(modulus, 0]` for `modulus < 0`, /// and it exists if and only if `gcd(self, modulus) == 1`. /// /// ``` /// use num_bigint::BigInt; /// use num_integer::Integer; /// use num_traits::{One, Zero}; /// /// let m = BigInt::from(383); /// /// // Trivial cases /// assert_eq!(BigInt::zero().modinv(&m), None); /// assert_eq!(BigInt::one().modinv(&m), Some(BigInt::one())); /// let neg1 = &m - 1u32; /// assert_eq!(neg1.modinv(&m), Some(neg1)); /// /// // Positive self and modulus /// let a = BigInt::from(271); /// let x = a.modinv(&m).unwrap(); /// assert_eq!(x, BigInt::from(106)); /// assert_eq!(x.modinv(&m).unwrap(), a); /// assert_eq!((&a * x).mod_floor(&m), BigInt::one()); /// /// // Negative self and positive modulus /// let b = -&a; /// let x = b.modinv(&m).unwrap(); /// assert_eq!(x, BigInt::from(277)); /// assert_eq!((&b * x).mod_floor(&m), BigInt::one()); /// /// // Positive self and negative modulus /// let n = -&m; /// let x = a.modinv(&n).unwrap(); /// assert_eq!(x, BigInt::from(-277)); /// assert_eq!((&a * x).mod_floor(&n), &n + 1); /// /// // Negative self and modulus /// let x = b.modinv(&n).unwrap(); /// assert_eq!(x, BigInt::from(-106)); /// assert_eq!((&b * x).mod_floor(&n), &n + 1); /// ``` pubfn modinv(&self, modulus: &Self) -> Option<Self> { let result = self.data.modinv(&modulus.data)?; // The sign of the result follows the modulus, like `mod_floor`. let (sign, mag) = match (self.is_negative(), modulus.is_negative()) {
(false, false) => (Plus, result),
(true, false) => (Plus, &modulus.data - result),
(false, true) => (Minus, &modulus.data - result),
(true, true) => (Minus, result),
};
Some(BigInt::from_biguint(sign, mag))
}
/// Returns the truncated principal square root of `self` -- /// see [`num_integer::Roots::sqrt()`]. pubfn sqrt(&self) -> Self {
Roots::sqrt(self)
}
/// Returns the truncated principal cube root of `self` -- /// see [`num_integer::Roots::cbrt()`]. pubfn cbrt(&self) -> Self {
Roots::cbrt(self)
}
/// Returns the truncated principal `n`th root of `self` -- /// See [`num_integer::Roots::nth_root()`]. pubfn nth_root(&self, n: u32) -> Self {
Roots::nth_root(self, n)
}
/// Returns the number of least-significant bits that are zero, /// or `None` if the entire number is zero. pubfn trailing_zeros(&self) -> Option<u64> { self.data.trailing_zeros()
}
/// Returns whether the bit in position `bit` is set, /// using the two's complement for negative numbers pubfn bit(&self, bit: u64) -> bool { ifself.is_negative() { // Let the binary representation of a number be // ... 0 x 1 0 ... 0 // Then the two's complement is // ... 1 !x 1 0 ... 0 // where !x is obtained from x by flipping each bit if bit >= u64::from(crate::big_digit::BITS) * self.len() as u64 { true
} else { let trailing_zeros = self.data.trailing_zeros().unwrap(); match Ord::cmp(&bit, &trailing_zeros) {
Ordering::Less => false,
Ordering::Equal => true,
Ordering::Greater => !self.data.bit(bit),
}
}
} else { self.data.bit(bit)
}
}
/// Sets or clears the bit in the given position, /// using the two's complement for negative numbers /// /// Note that setting/clearing a bit (for positive/negative numbers, /// respectively) greater than the current bit length, a reallocation /// may be needed to store the new digits pubfn set_bit(&mutself, bit: u64, value: bool) { matchself.sign {
Sign::Plus => self.data.set_bit(bit, value),
Sign::Minus => bits::set_negative_bit(self, bit, value),
Sign::NoSign => { if value { self.data.set_bit(bit, true); self.sign = Sign::Plus;
} else { // Clearing a bit for zero is a no-op
}
}
} // The top bit may have been cleared, so normalize self.normalize();
}
}
impl num_traits::FromBytes for BigInt { type Bytes = [u8];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.