pub struct Integer(/* private fields */);Implementations§
Source§impl Integer
impl Integer
pub const ZERO: Self
pub const ONE: Self
Sourcepub fn from_radix_digits(digits: &str, radix: u32) -> Result<Self, IntError>
pub fn from_radix_digits(digits: &str, radix: u32) -> Result<Self, IntError>
Parse unsigned binary or hexadecimal digits (no prefix or separators). Check the significant bit count before allocating a bigint. Decimal parsing remains separate so data files keep their decimal-only contract.
pub fn from_big(value: BigInt) -> Result<Self, IntError>
pub fn big(&self) -> Cow<'_, BigInt>
pub fn to_i64(&self) -> Option<i64>
pub fn to_u64(&self) -> Option<u64>
pub fn to_u128(&self) -> Option<u128>
pub fn to_f64(&self) -> Option<f64>
pub fn from_f64(x: f64) -> Option<Self>
pub fn bits(&self) -> u64
Sourcepub fn bit_and(&self, rhs: &Self) -> Result<Self, IntError>
pub fn bit_and(&self, rhs: &Self) -> Result<Self, IntError>
Signed bit operations use infinite two’s-complement sign extension.
pub fn bit_or(&self, rhs: &Self) -> Result<Self, IntError>
pub fn bit_xor(&self, rhs: &Self) -> Result<Self, IntError>
pub fn bit_not(&self) -> Result<Self, IntError>
pub fn is_negative(&self) -> bool
pub fn is_zero(&self) -> bool
pub fn is_odd(&self) -> bool
pub fn magnitude_bit(&self, i: u64) -> bool
pub fn negated(&self) -> Self
pub fn abs(&self) -> Self
pub fn add(&self, rhs: &Self) -> Result<Self, IntError>
pub fn sub(&self, rhs: &Self) -> Result<Self, IntError>
pub fn mul(&self, rhs: &Self) -> Result<Self, IntError>
pub fn div_mod(&self, rhs: &Self) -> Result<(Self, Self), IntError>
pub fn pow(&self, exponent: u32) -> Result<Self, IntError>
Sourcepub fn ratio(&self, denominator: &Self) -> Option<f64>
pub fn ratio(&self, denominator: &Self) -> Option<f64>
Convert the quotient jointly: individually converting huge operands would turn a finite ratio into infinity / infinity.
Sourcepub fn probability_rank(&self, p: f64) -> Result<Self, IntError>
pub fn probability_rank(&self, p: f64) -> Result<Self, IntError>
ceil(n*p) for a nonnegative n and a finite probability. The float is interpreted exactly, so rank selection works beyond float precision. The temporary product uses at most 53 extra bits above n’s size.
Sourcepub fn round_decimal(&self, places: u32) -> Result<Self, IntError>
pub fn round_decimal(&self, places: u32) -> Result<Self, IntError>
Round an integer to a power of ten, halfway away from zero. The temporary scale is bounded to at most a few bits above the value ceiling.
Trait Implementations§
impl Eq for Integer
Source§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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Integer
impl PartialOrd 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