pub struct Int(/* private fields */);Expand description
Garbage collected big integer that implements Copy and supports construction in const contexts.
Implementations§
source§impl Int
impl Int
sourcepub fn is_power_of_two(self) -> bool
pub fn is_power_of_two(self) -> bool
Returns true if self is a power of two. false otherwise.
sourcepub fn next_power_of_two(self) -> Int
pub fn next_power_of_two(self) -> Int
Returns the smallest power of two greater than or equal to self.
sourcepub fn checked_div(self, other: Int) -> Option<Int>
pub fn checked_div(self, other: Int) -> Option<Int>
Checked integer division.
Returns None if and only if other == 0.
sourcepub fn trailing_zeros(self) -> Option<Int>
pub fn trailing_zeros(self) -> Option<Int>
Returns the number of least-significant bits that are zero or None if the entire number is zero.
sourcepub fn div_ceil(self, other: impl Into<Int>) -> Int
pub fn div_ceil(self, other: impl Into<Int>) -> Int
Divides self by other and rounds up the result.
sourcepub fn div_euclid(self, other: Int) -> Int
pub fn div_euclid(self, other: Int) -> Int
Calculates Euclidean division: the result is rounded towards -INF
for other > 0 and towards +INF for other < 0.
The result n satisfies self == n * other + self.rem_euclid(other).
sourcepub fn rem_euclid(self, other: Int) -> Int
pub fn rem_euclid(self, other: Int) -> Int
Calculate nonnegative remainder of self (mod other).
The return value is in the range 0..other.abs().
sourcepub fn bring_in_bounds(self, signed: Signedness, size: Size) -> Int
pub fn bring_in_bounds(self, signed: Signedness, size: Size) -> Int
Returns the unique value that is equal to self modulo 2^size.bits()
and within the bounds of a finite integer type with the given signedness and size.
If signed == Unsigned the result is in the interval 0..2^size.bits().
Otherwise it is in the interval -2^(size.bits()-1) .. 2^(size.bits()-1).
size must not be zero.
sourcepub fn in_bounds(self, signed: Signedness, size: Size) -> bool
pub fn in_bounds(self, signed: Signedness, size: Size) -> bool
Tests whether an integer is in-bounds of a finite integer type.
Trait Implementations§
source§impl<T: Into<Int>> AddAssign<T> for Int
impl<T: Into<Int>> AddAssign<T> for Int
source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+= operation. Read moresource§impl Distribution<Int> for IntDistribution
impl Distribution<Int> for IntDistribution
source§impl<T: Into<Int>> DivAssign<T> for Int
impl<T: Into<Int>> DivAssign<T> for Int
source§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
/= operation. Read moresource§impl<T: Into<Int>> MulAssign<T> for Int
impl<T: Into<Int>> MulAssign<T> for Int
source§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
*= operation. Read moresource§impl Ord for Int
impl Ord for Int
source§impl<T: Into<Int> + Clone> PartialOrd<T> for Int
impl<T: Into<Int> + Clone> PartialOrd<T> for Int
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<T: Into<Int>> RemAssign<T> for Int
impl<T: Into<Int>> RemAssign<T> for Int
source§fn rem_assign(&mut self, other: T)
fn rem_assign(&mut self, other: T)
%= operation. Read moresource§impl<T: Into<Int>> ShlAssign<T> for Int
impl<T: Into<Int>> ShlAssign<T> for Int
source§fn shl_assign(&mut self, other: T)
fn shl_assign(&mut self, other: T)
<<= operation. Read moresource§impl<T: Into<Int>> ShrAssign<T> for Int
impl<T: Into<Int>> ShrAssign<T> for Int
source§fn shr_assign(&mut self, other: T)
fn shr_assign(&mut self, other: T)
>>= operation. Read moresource§impl Step for Int
impl Step for Int
source§fn steps_between(start: &Self, end: &Self) -> Option<usize>
fn steps_between(start: &Self, end: &Self) -> Option<usize>
step_trait)source§fn forward_checked(start: Self, count: usize) -> Option<Self>
fn forward_checked(start: Self, count: usize) -> Option<Self>
step_trait)source§fn backward_checked(start: Self, count: usize) -> Option<Self>
fn backward_checked(start: Self, count: usize) -> Option<Self>
step_trait)source§fn forward(start: Self, count: usize) -> Self
fn forward(start: Self, count: usize) -> Self
step_trait)source§unsafe fn forward_unchecked(start: Self, count: usize) -> Self
unsafe fn forward_unchecked(start: Self, count: usize) -> Self
step_trait)source§fn backward(start: Self, count: usize) -> Self
fn backward(start: Self, count: usize) -> Self
step_trait)source§unsafe fn backward_unchecked(start: Self, count: usize) -> Self
unsafe fn backward_unchecked(start: Self, count: usize) -> Self
step_trait)source§impl<T: Into<Int>> SubAssign<T> for Int
impl<T: Into<Int>> SubAssign<T> for Int
source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-= operation. Read more