pub struct BigInt { /* private fields */ }
Implementations§
Source§impl BigInt
impl BigInt
pub fn mul_bi(&self, other: &BigInt) -> Self
pub fn mul_bi_mut(&mut self, other: &BigInt)
pub fn mul_i32(&self, other: i32) -> Self
pub fn mul_i32_mut(&mut self, other: i32)
Sourcepub fn mul_pow2_mut(&mut self, exp: u32)
pub fn mul_pow2_mut(&mut self, exp: u32)
self *= 2^exp
Source§impl BigInt
impl BigInt
Sourcepub fn eq_bi(&self, other: &BigInt) -> bool
pub fn eq_bi(&self, other: &BigInt) -> bool
Though PartialEq
is implemented for BigInt
, this method exists.
That’s for consistency.
pub fn neq_bi(&self, other: &BigInt) -> bool
pub fn comp_bi(&self, other: &BigInt) -> Ordering
pub fn eq_i32(&self, other: i32) -> bool
pub fn neq_i32(&self, other: i32) -> bool
pub fn comp_i32(&self, other: i32) -> Ordering
Source§impl BigInt
impl BigInt
pub fn from_i32(n: i32) -> Self
pub fn to_i32(&self) -> Result<i32, ConversionError>
pub fn from_i64(n: i64) -> Self
pub fn to_i64(&self) -> Result<i64, ConversionError>
pub fn from_i128(n: i128) -> Self
pub fn to_i128(&self) -> Result<i128, ConversionError>
pub fn from_ubi(n: UBigInt, is_neg: bool) -> Self
pub fn to_ubi(&self) -> Result<UBigInt, ConversionError>
Sourcepub fn from_string(s: &str) -> Result<Self, ConversionError>
pub fn from_string(s: &str) -> Result<Self, ConversionError>
('-')? UBigInt
see UBigInt::from_string
Sourcepub fn to_scientific_notation(&self, digits_max_len: usize) -> String
pub fn to_scientific_notation(&self, digits_max_len: usize) -> String
‘9.8e5’
Sourcepub fn to_string_dec(&self) -> String
pub fn to_string_dec(&self) -> String
see UBigInt::to_string_dec
Sourcepub fn to_string_hex(&self, prefix: bool) -> String
pub fn to_string_hex(&self, prefix: bool) -> String
see UBigInt::to_string_hex
Sourcepub fn to_string_oct(&self, prefix: bool) -> String
pub fn to_string_oct(&self, prefix: bool) -> String
see UBigInt::to_string_oct
Sourcepub fn to_string_bin(&self, prefix: bool) -> String
pub fn to_string_bin(&self, prefix: bool) -> String
see UBigInt::to_string_bin
Source§impl BigInt
impl BigInt
Sourcepub fn log2_accurate(&self) -> Self
pub fn log2_accurate(&self) -> Self
It returns truncate(log2(abs(self)) * 4294967296)
. It returns 0 when self
is 0.
pub fn neg(&self) -> Self
pub fn neg_mut(&mut self)
pub fn abs(&self) -> Self
pub fn abs_mut(&mut self)
Sourcepub fn prime_factorial(&self) -> Vec<Self>
pub fn prime_factorial(&self) -> Vec<Self>
Sign of self
doesn’t make any difference
pub fn factorial(n: u32) -> Self
pub fn fibonacci(n: u32) -> Self
Sourcepub fn shift_right(&self, n: usize) -> Self
pub fn shift_right(&self, n: usize) -> Self
divide by 2^32
Sourcepub fn shift_right_mut(&mut self, n: usize)
pub fn shift_right_mut(&mut self, n: usize)
divide by 2^32
Sourcepub fn shift_left(&self, n: usize) -> Self
pub fn shift_left(&self, n: usize) -> Self
multiply 2^32
Sourcepub fn shift_left_mut(&mut self, n: usize)
pub fn shift_left_mut(&mut self, n: usize)
multiply 2^32
Sourcepub fn slice_right(&self, n: usize) -> Self
pub fn slice_right(&self, n: usize) -> Self
modulo 2^32 (it doesn’t care about sign)
It panics when n
is too big. It returns 0 when n
is 0.
Sourcepub fn slice_right_mut(&mut self, n: usize)
pub fn slice_right_mut(&mut self, n: usize)
modulo 2^32 (it doesn’t care about sign)
It panics when n
is too big. It makes self
0 when n
is 0.
Trait Implementations§
Source§impl Ord for BigInt
impl Ord for BigInt
Source§impl PartialOrd for BigInt
impl PartialOrd for BigInt
Source§impl TryFrom<&f32> for BigInt
impl TryFrom<&f32> for BigInt
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
Source§impl TryFrom<&f64> for BigInt
impl TryFrom<&f64> for BigInt
Source§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
impl Eq for BigInt
impl StructuralPartialEq for BigInt
Auto Trait Implementations§
impl Freeze for BigInt
impl RefUnwindSafe for BigInt
impl Send for BigInt
impl Sync for BigInt
impl Unpin for BigInt
impl UnwindSafe for BigInt
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