pub struct Aint<R: Sealed, const WIDTH: u32>(/* private fields */);
Expand description
An integer with a given representation, R
, and bit width, WIDTH
.
Implementations§
source§impl<const WIDTH: u32> Aint<u8, WIDTH>
impl<const WIDTH: u32> Aint<u8, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: u8) -> Self
pub const unsafe fn new_unchecked(repr: u8) -> Self
sourcepub const fn new(repr: u8) -> Option<Self>
pub const fn new(repr: u8) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: u8) -> Self
pub const fn new_wrapping(repr: u8) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: u8) -> Self
pub const fn new_saturating(repr: u8) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: u8) -> (Self, bool)
pub const fn new_overflowing(repr: u8) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> u8
pub const fn repr(self) -> u8
Returns the value of this integer as the underlying representation type.
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Self
pub const fn abs_diff(self, rhs: Self) -> Self
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl<const WIDTH: u32> Aint<u16, WIDTH>
impl<const WIDTH: u32> Aint<u16, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: u16) -> Self
pub const unsafe fn new_unchecked(repr: u16) -> Self
sourcepub const fn new(repr: u16) -> Option<Self>
pub const fn new(repr: u16) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: u16) -> Self
pub const fn new_wrapping(repr: u16) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: u16) -> Self
pub const fn new_saturating(repr: u16) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: u16) -> (Self, bool)
pub const fn new_overflowing(repr: u16) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> u16
pub const fn repr(self) -> u16
Returns the value of this integer as the underlying representation type.
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Self
pub const fn abs_diff(self, rhs: Self) -> Self
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl<const WIDTH: u32> Aint<u32, WIDTH>
impl<const WIDTH: u32> Aint<u32, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: u32) -> Self
pub const unsafe fn new_unchecked(repr: u32) -> Self
sourcepub const fn new(repr: u32) -> Option<Self>
pub const fn new(repr: u32) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: u32) -> Self
pub const fn new_wrapping(repr: u32) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: u32) -> Self
pub const fn new_saturating(repr: u32) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: u32) -> (Self, bool)
pub const fn new_overflowing(repr: u32) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> u32
pub const fn repr(self) -> u32
Returns the value of this integer as the underlying representation type.
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Self
pub const fn abs_diff(self, rhs: Self) -> Self
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl Aint<u32, 24>
impl Aint<u32, 24>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 3]) -> Self
pub const fn from_be_bytes(bytes: [u8; 3]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 3]) -> Self
pub const fn from_le_bytes(bytes: [u8; 3]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 3]
pub const fn to_be_bytes(self) -> [u8; 3]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 3]
pub const fn to_le_bytes(self) -> [u8; 3]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 3]
pub const fn to_ne_bytes(self) -> [u8; 3]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl<const WIDTH: u32> Aint<u64, WIDTH>
impl<const WIDTH: u32> Aint<u64, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: u64) -> Self
pub const unsafe fn new_unchecked(repr: u64) -> Self
sourcepub const fn new(repr: u64) -> Option<Self>
pub const fn new(repr: u64) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: u64) -> Self
pub const fn new_wrapping(repr: u64) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: u64) -> Self
pub const fn new_saturating(repr: u64) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: u64) -> (Self, bool)
pub const fn new_overflowing(repr: u64) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> u64
pub const fn repr(self) -> u64
Returns the value of this integer as the underlying representation type.
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Self
pub const fn abs_diff(self, rhs: Self) -> Self
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl Aint<u64, 40>
impl Aint<u64, 40>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 5]) -> Self
pub const fn from_be_bytes(bytes: [u8; 5]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 5]) -> Self
pub const fn from_le_bytes(bytes: [u8; 5]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 5]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 5]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 5]
pub const fn to_be_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 5]
pub const fn to_le_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 5]
pub const fn to_ne_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u64, 48>
impl Aint<u64, 48>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 6]) -> Self
pub const fn from_be_bytes(bytes: [u8; 6]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 6]) -> Self
pub const fn from_le_bytes(bytes: [u8; 6]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 6]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 6]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 6]
pub const fn to_be_bytes(self) -> [u8; 6]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 6]
pub const fn to_le_bytes(self) -> [u8; 6]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 6]
pub const fn to_ne_bytes(self) -> [u8; 6]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u64, 56>
impl Aint<u64, 56>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 7]) -> Self
pub const fn from_be_bytes(bytes: [u8; 7]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 7]) -> Self
pub const fn from_le_bytes(bytes: [u8; 7]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 7]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 7]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 7]
pub const fn to_be_bytes(self) -> [u8; 7]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 7]
pub const fn to_le_bytes(self) -> [u8; 7]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 7]
pub const fn to_ne_bytes(self) -> [u8; 7]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl<const WIDTH: u32> Aint<u128, WIDTH>
impl<const WIDTH: u32> Aint<u128, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: u128) -> Self
pub const unsafe fn new_unchecked(repr: u128) -> Self
sourcepub const fn new(repr: u128) -> Option<Self>
pub const fn new(repr: u128) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: u128) -> Self
pub const fn new_wrapping(repr: u128) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: u128) -> Self
pub const fn new_saturating(repr: u128) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: u128) -> (Self, bool)
pub const fn new_overflowing(repr: u128) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> u128
pub const fn repr(self) -> u128
Returns the value of this integer as the underlying representation type.
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Self
pub const fn abs_diff(self, rhs: Self) -> Self
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl Aint<u128, 72>
impl Aint<u128, 72>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 9]) -> Self
pub const fn from_be_bytes(bytes: [u8; 9]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 9]) -> Self
pub const fn from_le_bytes(bytes: [u8; 9]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 9]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 9]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 9]
pub const fn to_be_bytes(self) -> [u8; 9]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 9]
pub const fn to_le_bytes(self) -> [u8; 9]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 9]
pub const fn to_ne_bytes(self) -> [u8; 9]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u128, 80>
impl Aint<u128, 80>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 10]) -> Self
pub const fn from_be_bytes(bytes: [u8; 10]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 10]) -> Self
pub const fn from_le_bytes(bytes: [u8; 10]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 10]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 10]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 10]
pub const fn to_be_bytes(self) -> [u8; 10]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 10]
pub const fn to_le_bytes(self) -> [u8; 10]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 10]
pub const fn to_ne_bytes(self) -> [u8; 10]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u128, 88>
impl Aint<u128, 88>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 11]) -> Self
pub const fn from_be_bytes(bytes: [u8; 11]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 11]) -> Self
pub const fn from_le_bytes(bytes: [u8; 11]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 11]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 11]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 11]
pub const fn to_be_bytes(self) -> [u8; 11]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 11]
pub const fn to_le_bytes(self) -> [u8; 11]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 11]
pub const fn to_ne_bytes(self) -> [u8; 11]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u128, 96>
impl Aint<u128, 96>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 12]) -> Self
pub const fn from_be_bytes(bytes: [u8; 12]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 12]) -> Self
pub const fn from_le_bytes(bytes: [u8; 12]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 12]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 12]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 12]
pub const fn to_be_bytes(self) -> [u8; 12]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 12]
pub const fn to_le_bytes(self) -> [u8; 12]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 12]
pub const fn to_ne_bytes(self) -> [u8; 12]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u128, 104>
impl Aint<u128, 104>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 13]) -> Self
pub const fn from_be_bytes(bytes: [u8; 13]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 13]) -> Self
pub const fn from_le_bytes(bytes: [u8; 13]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 13]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 13]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 13]
pub const fn to_be_bytes(self) -> [u8; 13]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 13]
pub const fn to_le_bytes(self) -> [u8; 13]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 13]
pub const fn to_ne_bytes(self) -> [u8; 13]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u128, 112>
impl Aint<u128, 112>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 14]) -> Self
pub const fn from_be_bytes(bytes: [u8; 14]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 14]) -> Self
pub const fn from_le_bytes(bytes: [u8; 14]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 14]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 14]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 14]
pub const fn to_be_bytes(self) -> [u8; 14]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 14]
pub const fn to_le_bytes(self) -> [u8; 14]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 14]
pub const fn to_ne_bytes(self) -> [u8; 14]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<u128, 120>
impl Aint<u128, 120>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 15]) -> Self
pub const fn from_be_bytes(bytes: [u8; 15]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 15]) -> Self
pub const fn from_le_bytes(bytes: [u8; 15]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 15]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 15]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 15]
pub const fn to_be_bytes(self) -> [u8; 15]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 15]
pub const fn to_le_bytes(self) -> [u8; 15]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 15]
pub const fn to_ne_bytes(self) -> [u8; 15]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl<const WIDTH: u32> Aint<i8, WIDTH>
impl<const WIDTH: u32> Aint<i8, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: i8) -> Self
pub const unsafe fn new_unchecked(repr: i8) -> Self
sourcepub const fn new(repr: i8) -> Option<Self>
pub const fn new(repr: i8) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: i8) -> Self
pub const fn new_wrapping(repr: i8) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: i8) -> Self
pub const fn new_saturating(repr: i8) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: i8) -> (Self, bool)
pub const fn new_overflowing(repr: i8) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> i8
pub const fn repr(self) -> i8
Returns the value of this integer as the underlying representation type.
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true
if this integer is less than zero.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true
if this integer is greater than zero.
sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns the sign of the integer.
- If
self < 0
, returns-1
- If
self > 0
, returns1
- If
self == 0
, returns0
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn neg(self) -> Self
pub const fn neg(self) -> Self
Calculates the negative of this integer.
This method works as a const
capable alternative to -self
.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_abs(self) -> Self
pub const fn wrapping_abs(self) -> Self
Wrapping (modular) aboslute value. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_abs(self) -> (Self, bool)
pub const fn overflowing_abs(self) -> (Self, bool)
Calculates self.abs()
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Aint<u8, WIDTH>
pub const fn abs_diff(self, rhs: Self) -> Aint<u8, WIDTH>
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl<const WIDTH: u32> Aint<i16, WIDTH>
impl<const WIDTH: u32> Aint<i16, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: i16) -> Self
pub const unsafe fn new_unchecked(repr: i16) -> Self
sourcepub const fn new(repr: i16) -> Option<Self>
pub const fn new(repr: i16) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: i16) -> Self
pub const fn new_wrapping(repr: i16) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: i16) -> Self
pub const fn new_saturating(repr: i16) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: i16) -> (Self, bool)
pub const fn new_overflowing(repr: i16) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> i16
pub const fn repr(self) -> i16
Returns the value of this integer as the underlying representation type.
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true
if this integer is less than zero.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true
if this integer is greater than zero.
sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns the sign of the integer.
- If
self < 0
, returns-1
- If
self > 0
, returns1
- If
self == 0
, returns0
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn neg(self) -> Self
pub const fn neg(self) -> Self
Calculates the negative of this integer.
This method works as a const
capable alternative to -self
.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_abs(self) -> Self
pub const fn wrapping_abs(self) -> Self
Wrapping (modular) aboslute value. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_abs(self) -> (Self, bool)
pub const fn overflowing_abs(self) -> (Self, bool)
Calculates self.abs()
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Aint<u16, WIDTH>
pub const fn abs_diff(self, rhs: Self) -> Aint<u16, WIDTH>
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl<const WIDTH: u32> Aint<i32, WIDTH>
impl<const WIDTH: u32> Aint<i32, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: i32) -> Self
pub const unsafe fn new_unchecked(repr: i32) -> Self
sourcepub const fn new(repr: i32) -> Option<Self>
pub const fn new(repr: i32) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: i32) -> Self
pub const fn new_wrapping(repr: i32) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: i32) -> Self
pub const fn new_saturating(repr: i32) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: i32) -> (Self, bool)
pub const fn new_overflowing(repr: i32) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> i32
pub const fn repr(self) -> i32
Returns the value of this integer as the underlying representation type.
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true
if this integer is less than zero.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true
if this integer is greater than zero.
sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns the sign of the integer.
- If
self < 0
, returns-1
- If
self > 0
, returns1
- If
self == 0
, returns0
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn neg(self) -> Self
pub const fn neg(self) -> Self
Calculates the negative of this integer.
This method works as a const
capable alternative to -self
.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_abs(self) -> Self
pub const fn wrapping_abs(self) -> Self
Wrapping (modular) aboslute value. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_abs(self) -> (Self, bool)
pub const fn overflowing_abs(self) -> (Self, bool)
Calculates self.abs()
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Aint<u32, WIDTH>
pub const fn abs_diff(self, rhs: Self) -> Aint<u32, WIDTH>
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl Aint<i32, 24>
impl Aint<i32, 24>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 3]) -> Self
pub const fn from_be_bytes(bytes: [u8; 3]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 3]) -> Self
pub const fn from_le_bytes(bytes: [u8; 3]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 3]
pub const fn to_be_bytes(self) -> [u8; 3]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 3]
pub const fn to_le_bytes(self) -> [u8; 3]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 3]
pub const fn to_ne_bytes(self) -> [u8; 3]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl<const WIDTH: u32> Aint<i64, WIDTH>
impl<const WIDTH: u32> Aint<i64, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: i64) -> Self
pub const unsafe fn new_unchecked(repr: i64) -> Self
sourcepub const fn new(repr: i64) -> Option<Self>
pub const fn new(repr: i64) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: i64) -> Self
pub const fn new_wrapping(repr: i64) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: i64) -> Self
pub const fn new_saturating(repr: i64) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: i64) -> (Self, bool)
pub const fn new_overflowing(repr: i64) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> i64
pub const fn repr(self) -> i64
Returns the value of this integer as the underlying representation type.
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true
if this integer is less than zero.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true
if this integer is greater than zero.
sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns the sign of the integer.
- If
self < 0
, returns-1
- If
self > 0
, returns1
- If
self == 0
, returns0
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn neg(self) -> Self
pub const fn neg(self) -> Self
Calculates the negative of this integer.
This method works as a const
capable alternative to -self
.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_abs(self) -> Self
pub const fn wrapping_abs(self) -> Self
Wrapping (modular) aboslute value. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_abs(self) -> (Self, bool)
pub const fn overflowing_abs(self) -> (Self, bool)
Calculates self.abs()
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Aint<u64, WIDTH>
pub const fn abs_diff(self, rhs: Self) -> Aint<u64, WIDTH>
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl Aint<i64, 40>
impl Aint<i64, 40>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 5]) -> Self
pub const fn from_be_bytes(bytes: [u8; 5]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 5]) -> Self
pub const fn from_le_bytes(bytes: [u8; 5]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 5]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 5]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 5]
pub const fn to_be_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 5]
pub const fn to_le_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 5]
pub const fn to_ne_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i64, 48>
impl Aint<i64, 48>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 6]) -> Self
pub const fn from_be_bytes(bytes: [u8; 6]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 6]) -> Self
pub const fn from_le_bytes(bytes: [u8; 6]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 6]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 6]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 6]
pub const fn to_be_bytes(self) -> [u8; 6]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 6]
pub const fn to_le_bytes(self) -> [u8; 6]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 6]
pub const fn to_ne_bytes(self) -> [u8; 6]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i64, 56>
impl Aint<i64, 56>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 7]) -> Self
pub const fn from_be_bytes(bytes: [u8; 7]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 7]) -> Self
pub const fn from_le_bytes(bytes: [u8; 7]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 7]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 7]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 7]
pub const fn to_be_bytes(self) -> [u8; 7]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 7]
pub const fn to_le_bytes(self) -> [u8; 7]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 7]
pub const fn to_ne_bytes(self) -> [u8; 7]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl<const WIDTH: u32> Aint<i128, WIDTH>
impl<const WIDTH: u32> Aint<i128, WIDTH>
sourcepub const unsafe fn new_unchecked(repr: i128) -> Self
pub const unsafe fn new_unchecked(repr: i128) -> Self
sourcepub const fn new(repr: i128) -> Option<Self>
pub const fn new(repr: i128) -> Option<Self>
Creates a new integer value from the underlying representation type.
The returned value is None
if the representation value is outside the range of valid
values of this integer type.
sourcepub const fn new_wrapping(repr: i128) -> Self
pub const fn new_wrapping(repr: i128) -> Self
Creates a new integer value from the underlying representation type.
The returned value is wrapped as though the representation value were calculated using
wrapping operations, such as wrapping_add
.
sourcepub const fn new_saturating(repr: i128) -> Self
pub const fn new_saturating(repr: i128) -> Self
Creates a new integer value from the underlying representation type.
The returned value is saturated to the bounds of this integer’s value range. If the
representation value is greater than MAX
, the returned value will be
MAX
. If the representation value is less than MIN
, the
returned value will be MIN
.
sourcepub const fn new_overflowing(repr: i128) -> (Self, bool)
pub const fn new_overflowing(repr: i128) -> (Self, bool)
Creates a new integer from the underlying representation type.
The returned tuple contains the new integer and a bool
indicating if the representation
value overflowed the new integer. In the case of overflow, the new integer has a value
as if it were produced from new_wrapping
.
sourcepub const fn repr(self) -> i128
pub const fn repr(self) -> i128
Returns the value of this integer as the underlying representation type.
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true
if this integer is less than zero.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true
if this integer is greater than zero.
sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns the sign of the integer.
- If
self < 0
, returns-1
- If
self > 0
, returns1
- If
self == 0
, returns0
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of this integer.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representatino of this integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary represnetation of this integer.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representatino of this integer.
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of this integer.
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of this integer.
sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Performs a left bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the <<
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Performs a right bit shift by n
, wrapping the truncated bits back to the end.
Note that unlike the >>
operator, all values of n
are valid. A value of n
, that
is greater than or equal to BITS
, is the equivalent to using the value
n % Self::BITS
.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of the bits in the binary representation of this integer.
sourcepub const fn neg(self) -> Self
pub const fn neg(self) -> Self
Calculates the negative of this integer.
This method works as a const
capable alternative to -self
.
sourcepub const fn add(self, rhs: Self) -> Self
pub const fn add(self, rhs: Self) -> Self
Calculates the sum of this integer with another integer.
This method works as a const
capable alternative to self + rhs
.
sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates the difference of this integer with another integer.
This method works as a const
capable alternative to self - rhs
.
sourcepub const fn mul(self, rhs: Self) -> Self
pub const fn mul(self, rhs: Self) -> Self
Calculates the product of this integer with another integer.
This method works as a const
capable alternative to self * rhs
.
sourcepub const fn div(self, rhs: Self) -> Self
pub const fn div(self, rhs: Self) -> Self
Calculates the quotient of this integer over another integer.
This method works as a const
capable alternative to self / rhs
.
sourcepub const fn rem(self, rhs: Self) -> Self
pub const fn rem(self, rhs: Self) -> Self
Calculates the remainder of this integer over another integer.
This method works as a const
capable alternative to self % rhs
.
sourcepub const fn bitand(self, rhs: Self) -> Self
pub const fn bitand(self, rhs: Self) -> Self
Calculates the bitwise and of this integer with another integer.
This method works as a const
capable alternative to self & rhs
.
sourcepub const fn bitor(self, rhs: Self) -> Self
pub const fn bitor(self, rhs: Self) -> Self
Calculates the bitwise or of this integer with another integer.
This method works as a const
capable alternative to self | rhs
.
sourcepub const fn bitxor(self, rhs: Self) -> Self
pub const fn bitxor(self, rhs: Self) -> Self
Calculates the bitwise exclusive-or of this integer with another integer.
This method works as a const
capable alternative to self ^ rhs
.
sourcepub const fn not(self) -> Self
pub const fn not(self) -> Self
Calculates the bitwise negation of this integer.
This method works as a const
capable alternative to !self
.
sourcepub const fn shl(self, rhs: u32) -> Self
pub const fn shl(self, rhs: u32) -> Self
Calculates the left bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self << rhs
.
sourcepub const fn shr(self, rhs: u32) -> Self
pub const fn shr(self, rhs: u32) -> Self
Calculates the right bitwise shift of this integer by rhs
.
This method works as a const
capable alternative to self >> rhs
.
sourcepub const fn ilog(self, base: Self) -> u32
pub const fn ilog(self, base: Self) -> u32
Calculates the logarithm of this integer with respect to an arbitrary base, rounded down.
The ilog2
and ilog10
methods should be preferred
when applicable, as they are generally more optimized than this method since the base
of the logarithm is not arbitrary.
Panics
This method will panic if self
is less than or equal to zero, or if base
is less
than 2.
sourcepub const fn ilog2(self) -> u32
pub const fn ilog2(self) -> u32
Calculates the base 2 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn ilog10(self) -> u32
pub const fn ilog10(self) -> u32
Calculates the base 10 logarithm of this integer, rounded down.
Panics
This method will panic if self
is less than or equal to zero.
sourcepub const fn eq(self, rhs: Self) -> bool
pub const fn eq(self, rhs: Self) -> bool
Returns true
if self
and rhs
are equal.
This method works as a const
capable alternative to self == rhs
.
sourcepub const fn ne(self, rhs: Self) -> bool
pub const fn ne(self, rhs: Self) -> bool
Returns true
if self
and rhs
are not equal.
This method works as a const
capable alternative to self != rhs
.
sourcepub const fn lt(self, rhs: Self) -> bool
pub const fn lt(self, rhs: Self) -> bool
Returns true
if self
is less than rhs
.
This method works as a const
capable alternative to self < rhs
.
sourcepub const fn le(self, rhs: Self) -> bool
pub const fn le(self, rhs: Self) -> bool
Returns true
if self
is less than or equal to rhs
.
This method works as a const
capable alternative to self <= rhs
.
sourcepub const fn gt(self, rhs: Self) -> bool
pub const fn gt(self, rhs: Self) -> bool
Returns true
if self
is greater than rhs
.
This method works as a const
capable alternative to self > rhs
.
sourcepub const fn ge(self, rhs: Self) -> bool
pub const fn ge(self, rhs: Self) -> bool
Returns true
if self
is greater than or equal to rhs
.
This method works as a const
capable alternative to self >= rhs
.
sourcepub const fn cmp(self, rhs: Self) -> Ordering
pub const fn cmp(self, rhs: Self) -> Ordering
Returns the ordering of self
with respect to rhs
.
This method works as a const
capable alternative to Ord::cmp(self, rhs)
.
sourcepub const fn min(self, other: Self) -> Self
pub const fn min(self, other: Self) -> Self
Returns the minimum of self
and other
.
This method works as a const
capable alternative to Ord::min(self, rhs)
.
sourcepub const fn max(self, other: Self) -> Self
pub const fn max(self, other: Self) -> Self
Returns the maximum of self
and other
.
This method works as a const
capable alternative to Ord::max(self, rhs)
.
sourcepub const fn clamp(self, min: Self, max: Self) -> Self
pub const fn clamp(self, min: Self, max: Self) -> Self
Returns the value of this integer, clamped between min
and max
.
This method works as a const
capable alternative to Ord::clamp(self, min, max)
.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Returns None
if overflow occurred.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Returns None
if overflow occurred.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Returns None
if overflow occurred.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Returns None
if rhs
is zero, or the division resulted in
overflow.
sourcepub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian division. Returns None
if rhs
is zero or self.div_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Returns None
if rhs
is zero or the remainder would have
resulted in overflow.
sourcepub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
Checked euclidian remainder. Returns None
if rhs
is zero or self.rem_euclid(rhs)
would have resulted in overflow.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked integer negation. Returns None
if the negation resulted in overflow.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked left bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked right bit shift. Returns None
if rhs
is greater than or equal to
Self::BITS
.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Returns None
if the exponentiation resulted in overflow.
sourcepub const fn checked_ilog(self, base: Self) -> Option<u32>
pub const fn checked_ilog(self, base: Self) -> Option<u32>
Checked logarithm, rounded down. Returns None
if self
is less than or equal zero,
or if base
is less than 2.
sourcepub const fn checked_ilog2(self) -> Option<u32>
pub const fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm, rounded down. Returns None
if self is less than or equal to
zero.
sourcepub const fn checked_ilog10(self) -> Option<u32>
pub const fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm, rounded down. Returns None
if self is less than or equal
to zero.
sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_div_euclid(self, rhs: Self) -> Self
pub const fn wrapping_div_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian division. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self
Wrapping (modular) euclidian remainder. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping (modular) negation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Wrapping (modular) left bit shift. The value is left shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Wrapping (modular) right bit shift. The value is right shifted rhs % Self::BITS
bits.
sourcepub const fn wrapping_pow(self, exp: u32) -> Self
pub const fn wrapping_pow(self, exp: u32) -> Self
Wrapping (modular) exponentiation. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn wrapping_abs(self) -> Self
pub const fn wrapping_abs(self) -> Self
Wrapping (modular) aboslute value. An overflowing result is wrapped around the bounds of this integer type.
sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates self * rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates self / rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.div_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Calculates self % rhs
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)
Calculates self.rem_euclid(rhs)
, returning a tuple of the result and a bool
indicating if overflow occurred.
sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Calculates -self
, returning a tuple of the result and a bool
indicating if overflow
occurred.
sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Calculates self << rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Calculates self >> rhs
, returning a tuple of the result and a bool
indicating if
rhs
was greater than or equal to Self::BITS
.
sourcepub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub const fn overflowing_pow(self, exp: u32) -> (Self, bool)
Calculates self.pow(exp)
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn overflowing_abs(self) -> (Self, bool)
pub const fn overflowing_abs(self) -> (Self, bool)
Calculates self.abs()
, returning a tuple of the result and a bool
indicating if
overflow occurred.
sourcepub const fn pow(self, exp: u32) -> Self
pub const fn pow(self, exp: u32) -> Self
Raises self
to the power of exp
, using exponentiation by squaring.
sourcepub const fn div_euclid(self, rhs: Self) -> Self
pub const fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidian division self
by rhs
.
This computes the integer q
such that self = q * rhs + r
, with r = self.rem_euclid(rhs)
and 0 <= r < rhs.abs()
.
In other words, the result is self / rhs
, rounded to the integer q
such that self >= q * rhs
. If self > 0
, this is equal to round towards zero. If self < 0
, this is
equal to rounds towards +/- infinity.
sourcepub const fn rem_euclid(self, rhs: Self) -> Self
pub const fn rem_euclid(self, rhs: Self) -> Self
Calculates the non-negative remainder self (mod rhs)
.
This is done as if by the Euclidian division algorithm - given r = self.rem_euclid(rhs)
, self = self * self.div_euclid(rhs) + r
, and 0 <= r < r.abs()
.
sourcepub const fn abs_diff(self, rhs: Self) -> Aint<u128, WIDTH>
pub const fn abs_diff(self, rhs: Self) -> Aint<u128, WIDTH>
Computes the absolute difference between self
and rhs
.
This is equivalent to (self - rhs).abs()
without the posibility of intermediate
overflow.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base (radix
) to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace will result in an error. Digits are a subset of the following
characters depending on the radix
.
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
source§impl Aint<i128, 72>
impl Aint<i128, 72>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 9]) -> Self
pub const fn from_be_bytes(bytes: [u8; 9]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 9]) -> Self
pub const fn from_le_bytes(bytes: [u8; 9]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 9]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 9]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 9]
pub const fn to_be_bytes(self) -> [u8; 9]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 9]
pub const fn to_le_bytes(self) -> [u8; 9]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 9]
pub const fn to_ne_bytes(self) -> [u8; 9]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i128, 80>
impl Aint<i128, 80>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 10]) -> Self
pub const fn from_be_bytes(bytes: [u8; 10]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 10]) -> Self
pub const fn from_le_bytes(bytes: [u8; 10]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 10]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 10]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 10]
pub const fn to_be_bytes(self) -> [u8; 10]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 10]
pub const fn to_le_bytes(self) -> [u8; 10]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 10]
pub const fn to_ne_bytes(self) -> [u8; 10]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i128, 88>
impl Aint<i128, 88>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 11]) -> Self
pub const fn from_be_bytes(bytes: [u8; 11]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 11]) -> Self
pub const fn from_le_bytes(bytes: [u8; 11]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 11]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 11]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 11]
pub const fn to_be_bytes(self) -> [u8; 11]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 11]
pub const fn to_le_bytes(self) -> [u8; 11]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 11]
pub const fn to_ne_bytes(self) -> [u8; 11]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i128, 96>
impl Aint<i128, 96>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 12]) -> Self
pub const fn from_be_bytes(bytes: [u8; 12]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 12]) -> Self
pub const fn from_le_bytes(bytes: [u8; 12]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 12]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 12]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 12]
pub const fn to_be_bytes(self) -> [u8; 12]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 12]
pub const fn to_le_bytes(self) -> [u8; 12]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 12]
pub const fn to_ne_bytes(self) -> [u8; 12]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i128, 104>
impl Aint<i128, 104>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 13]) -> Self
pub const fn from_be_bytes(bytes: [u8; 13]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 13]) -> Self
pub const fn from_le_bytes(bytes: [u8; 13]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 13]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 13]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 13]
pub const fn to_be_bytes(self) -> [u8; 13]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 13]
pub const fn to_le_bytes(self) -> [u8; 13]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 13]
pub const fn to_ne_bytes(self) -> [u8; 13]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i128, 112>
impl Aint<i128, 112>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 14]) -> Self
pub const fn from_be_bytes(bytes: [u8; 14]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 14]) -> Self
pub const fn from_le_bytes(bytes: [u8; 14]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 14]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 14]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 14]
pub const fn to_be_bytes(self) -> [u8; 14]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 14]
pub const fn to_le_bytes(self) -> [u8; 14]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 14]
pub const fn to_ne_bytes(self) -> [u8; 14]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
source§impl Aint<i128, 120>
impl Aint<i128, 120>
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn from_be(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
Converts an integer from big endian to the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn from_le(x: Self) -> Self
pub const fn from_le(x: Self) -> Self
Converts an integer from little endian to the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn to_be(self) -> Self
pub const fn to_be(self) -> Self
Converts self
to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are swapped.
sourcepub const fn to_le(self) -> Self
pub const fn to_le(self) -> Self
Converts self
to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are swapped.
sourcepub const fn from_be_bytes(bytes: [u8; 15]) -> Self
pub const fn from_be_bytes(bytes: [u8; 15]) -> Self
Creates an integer value from its memory representation as a byte array in bit endian.
sourcepub const fn from_le_bytes(bytes: [u8; 15]) -> Self
pub const fn from_le_bytes(bytes: [u8; 15]) -> Self
Creates an integer value from its memory representation as a byte array in little endian.
sourcepub const fn from_ne_bytes(bytes: [u8; 15]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 15]) -> Self
Creates an integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely wants to
use from_be_bytes
or from_le_bytes
,
as appropriate instead.
sourcepub const fn to_be_bytes(self) -> [u8; 15]
pub const fn to_be_bytes(self) -> [u8; 15]
Return the memory representation of this integer as a byte array in big-endian byte order.
sourcepub const fn to_le_bytes(self) -> [u8; 15]
pub const fn to_le_bytes(self) -> [u8; 15]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub const fn to_ne_bytes(self) -> [u8; 15]
pub const fn to_ne_bytes(self) -> [u8; 15]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code likely wants to
use to_be_bytes
or to_le_bytes
, as
appropriate instead.
Trait Implementations§
source§impl<T, R: Sealed, const WIDTH: u32> AddAssign<T> for Aint<R, WIDTH>where
Self: Add<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> AddAssign<T> for Aint<R, WIDTH>where
Self: Add<T, Output = Self>,
source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> BitAndAssign<T> for Aint<R, WIDTH>where
Self: BitAnd<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> BitAndAssign<T> for Aint<R, WIDTH>where
Self: BitAnd<T, Output = Self>,
source§fn bitand_assign(&mut self, rhs: T)
fn bitand_assign(&mut self, rhs: T)
&=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> BitOrAssign<T> for Aint<R, WIDTH>where
Self: BitOr<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> BitOrAssign<T> for Aint<R, WIDTH>where
Self: BitOr<T, Output = Self>,
source§fn bitor_assign(&mut self, rhs: T)
fn bitor_assign(&mut self, rhs: T)
|=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> BitXorAssign<T> for Aint<R, WIDTH>where
Self: BitXor<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> BitXorAssign<T> for Aint<R, WIDTH>where
Self: BitXor<T, Output = Self>,
source§fn bitxor_assign(&mut self, rhs: T)
fn bitxor_assign(&mut self, rhs: T)
^=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> DivAssign<T> for Aint<R, WIDTH>where
Self: Div<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> DivAssign<T> for Aint<R, WIDTH>where
Self: Div<T, Output = Self>,
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> MulAssign<T> for Aint<R, WIDTH>where
Self: Mul<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> MulAssign<T> for Aint<R, WIDTH>where
Self: Mul<T, Output = Self>,
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*=
operation. Read moresource§impl<R: Ord + Sealed, const WIDTH: u32> Ord for Aint<R, WIDTH>
impl<R: Ord + Sealed, const WIDTH: u32> Ord for Aint<R, WIDTH>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<R: PartialEq + Sealed, const WIDTH: u32> PartialEq for Aint<R, WIDTH>
impl<R: PartialEq + Sealed, const WIDTH: u32> PartialEq for Aint<R, WIDTH>
source§impl<R: PartialOrd + Sealed, const WIDTH: u32> PartialOrd for Aint<R, WIDTH>
impl<R: PartialOrd + Sealed, const WIDTH: u32> PartialOrd for Aint<R, WIDTH>
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, R: Sealed, const WIDTH: u32> RemAssign<T> for Aint<R, WIDTH>where
Self: Rem<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> RemAssign<T> for Aint<R, WIDTH>where
Self: Rem<T, Output = Self>,
source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
%=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> SaturatingFrom<Aint<R, WIDTH>> for Twhere
T: SaturatingFrom<R> + Prim,
impl<T, R: Sealed, const WIDTH: u32> SaturatingFrom<Aint<R, WIDTH>> for Twhere
T: SaturatingFrom<R> + Prim,
fn saturating_from(value: Aint<R, WIDTH>) -> Self
source§impl<F: Prim, R, const WIDTH: u32> SaturatingFrom<F> for Aint<R, WIDTH>where
R: SaturatingFrom<F> + Sealed,
impl<F: Prim, R, const WIDTH: u32> SaturatingFrom<F> for Aint<R, WIDTH>where
R: SaturatingFrom<F> + Sealed,
fn saturating_from(value: F) -> Self
source§impl<'a, 'b, R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<&'b Aint<R2, WIDTH2>> for &'a Aint<R1, WIDTH1>
impl<'a, 'b, R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<&'b Aint<R2, WIDTH2>> for &'a Aint<R1, WIDTH1>
source§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<Aint<R2, WIDTH2>> for &Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<Aint<R2, WIDTH2>> for &Aint<R1, WIDTH1>
source§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shl<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i128
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i128
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i16
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i16
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i32
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i32
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i64
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i64
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i8
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for i8
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for isize
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for isize
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u128
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u128
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u16
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u16
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u32
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u32
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u64
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u64
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u8
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for u8
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for usize
impl<R: Sealed, const WIDTH: u32> ShlAssign<&Aint<R, WIDTH>> for usize
source§fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: &Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShlAssign<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShlAssign<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§fn shl_assign(&mut self, rhs: &Aint<R2, WIDTH2>)
fn shl_assign(&mut self, rhs: &Aint<R2, WIDTH2>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&i128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&i128> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &i128)
fn shl_assign(&mut self, rhs: &i128)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&i16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&i16> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &i16)
fn shl_assign(&mut self, rhs: &i16)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&i32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&i32> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &i32)
fn shl_assign(&mut self, rhs: &i32)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&i64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&i64> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &i64)
fn shl_assign(&mut self, rhs: &i64)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&i8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&i8> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &i8)
fn shl_assign(&mut self, rhs: &i8)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&isize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&isize> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &isize)
fn shl_assign(&mut self, rhs: &isize)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&u128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&u128> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &u128)
fn shl_assign(&mut self, rhs: &u128)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&u16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&u16> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &u16)
fn shl_assign(&mut self, rhs: &u16)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&u32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&u32> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &u32)
fn shl_assign(&mut self, rhs: &u32)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&u64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&u64> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &u64)
fn shl_assign(&mut self, rhs: &u64)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&u8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&u8> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &u8)
fn shl_assign(&mut self, rhs: &u8)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<&usize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<&usize> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i128
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i128
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i16
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i16
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i32
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i32
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i64
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i64
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i8
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for i8
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for isize
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for isize
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u128
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u128
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u16
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u16
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u32
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u32
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u64
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u64
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u8
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for u8
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for usize
impl<R: Sealed, const WIDTH: u32> ShlAssign<Aint<R, WIDTH>> for usize
source§fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shl_assign(&mut self, rhs: Aint<R, WIDTH>)
<<=
operation. Read moresource§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShlAssign<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShlAssign<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§fn shl_assign(&mut self, rhs: Aint<R2, WIDTH2>)
fn shl_assign(&mut self, rhs: Aint<R2, WIDTH2>)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<i128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<i128> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: i128)
fn shl_assign(&mut self, rhs: i128)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<i16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<i16> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: i16)
fn shl_assign(&mut self, rhs: i16)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<i32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<i32> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: i32)
fn shl_assign(&mut self, rhs: i32)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<i64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<i64> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: i64)
fn shl_assign(&mut self, rhs: i64)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<i8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<i8> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: i8)
fn shl_assign(&mut self, rhs: i8)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<isize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<isize> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: isize)
fn shl_assign(&mut self, rhs: isize)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<u128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<u128> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: u128)
fn shl_assign(&mut self, rhs: u128)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<u16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<u16> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: u16)
fn shl_assign(&mut self, rhs: u16)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<u32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<u32> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<u64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<u64> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: u64)
fn shl_assign(&mut self, rhs: u64)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<u8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<u8> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
<<=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShlAssign<usize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShlAssign<usize> for Aint<R, WIDTH>
source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<=
operation. Read moresource§impl<'a, 'b, R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<&'b Aint<R2, WIDTH2>> for &'a Aint<R1, WIDTH1>
impl<'a, 'b, R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<&'b Aint<R2, WIDTH2>> for &'a Aint<R1, WIDTH1>
source§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<Aint<R2, WIDTH2>> for &Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<Aint<R2, WIDTH2>> for &Aint<R1, WIDTH1>
source§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> Shr<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i128
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i128
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i16
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i16
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i32
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i32
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i64
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i64
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i8
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for i8
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for isize
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for isize
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u128
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u128
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u16
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u16
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u32
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u32
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u64
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u64
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u8
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for u8
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for usize
impl<R: Sealed, const WIDTH: u32> ShrAssign<&Aint<R, WIDTH>> for usize
source§fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: &Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShrAssign<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShrAssign<&Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§fn shr_assign(&mut self, rhs: &Aint<R2, WIDTH2>)
fn shr_assign(&mut self, rhs: &Aint<R2, WIDTH2>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&i128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&i128> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &i128)
fn shr_assign(&mut self, rhs: &i128)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&i16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&i16> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &i16)
fn shr_assign(&mut self, rhs: &i16)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&i32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&i32> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &i32)
fn shr_assign(&mut self, rhs: &i32)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&i64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&i64> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &i64)
fn shr_assign(&mut self, rhs: &i64)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&i8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&i8> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &i8)
fn shr_assign(&mut self, rhs: &i8)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&isize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&isize> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &isize)
fn shr_assign(&mut self, rhs: &isize)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&u128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&u128> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &u128)
fn shr_assign(&mut self, rhs: &u128)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&u16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&u16> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &u16)
fn shr_assign(&mut self, rhs: &u16)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&u32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&u32> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &u32)
fn shr_assign(&mut self, rhs: &u32)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&u64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&u64> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &u64)
fn shr_assign(&mut self, rhs: &u64)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&u8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&u8> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &u8)
fn shr_assign(&mut self, rhs: &u8)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<&usize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<&usize> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i128
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i128
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i16
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i16
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i32
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i32
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i64
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i64
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i8
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for i8
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for isize
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for isize
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u128
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u128
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u16
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u16
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u32
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u32
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u64
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u64
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u8
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for u8
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for usize
impl<R: Sealed, const WIDTH: u32> ShrAssign<Aint<R, WIDTH>> for usize
source§fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
fn shr_assign(&mut self, rhs: Aint<R, WIDTH>)
>>=
operation. Read moresource§impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShrAssign<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
impl<R1: Sealed, R2: Sealed, const WIDTH1: u32, const WIDTH2: u32> ShrAssign<Aint<R2, WIDTH2>> for Aint<R1, WIDTH1>
source§fn shr_assign(&mut self, rhs: Aint<R2, WIDTH2>)
fn shr_assign(&mut self, rhs: Aint<R2, WIDTH2>)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<i128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<i128> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: i128)
fn shr_assign(&mut self, rhs: i128)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<i16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<i16> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: i16)
fn shr_assign(&mut self, rhs: i16)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<i32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<i32> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: i32)
fn shr_assign(&mut self, rhs: i32)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<i64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<i64> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: i64)
fn shr_assign(&mut self, rhs: i64)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<i8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<i8> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: i8)
fn shr_assign(&mut self, rhs: i8)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<isize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<isize> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: isize)
fn shr_assign(&mut self, rhs: isize)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<u128> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<u128> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: u128)
fn shr_assign(&mut self, rhs: u128)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<u16> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<u16> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: u16)
fn shr_assign(&mut self, rhs: u16)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<u32> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<u32> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<u64> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<u64> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: u64)
fn shr_assign(&mut self, rhs: u64)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<u8> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<u8> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
>>=
operation. Read moresource§impl<R: Sealed, const WIDTH: u32> ShrAssign<usize> for Aint<R, WIDTH>
impl<R: Sealed, const WIDTH: u32> ShrAssign<usize> for Aint<R, WIDTH>
source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read moresource§impl<T, R: Sealed, const WIDTH: u32> SubAssign<T> for Aint<R, WIDTH>where
Self: Sub<T, Output = Self>,
impl<T, R: Sealed, const WIDTH: u32> SubAssign<T> for Aint<R, WIDTH>where
Self: Sub<T, Output = Self>,
source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read more