Struct amplify_num::u40
source · pub struct u40(/* private fields */);
Expand description
40-bit unsigned integer in the range 0..2^40
Implementations§
source§impl u40
impl u40
source§impl u40
impl u40
sourcepub fn checked_add<T>(self, rhs: T) -> Option<Self>
pub fn checked_add<T>(self, rhs: T) -> Option<Self>
Checked integer addition. Computes self + rhs
, returning None
if
overflow occurred.
sourcepub fn saturating_add<T>(self, rhs: T) -> Self
pub fn saturating_add<T>(self, rhs: T) -> Self
Saturating integer addition. Computes self + rhs
, saturating at the
numeric bounds instead of overflowing.
sourcepub fn overflowing_add<T>(self, rhs: T) -> (Self, bool)
pub fn overflowing_add<T>(self, rhs: T) -> (Self, bool)
Calculates self + rhs
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
sourcepub fn wrapping_add<T>(self, rhs: T) -> Self
pub fn wrapping_add<T>(self, rhs: T) -> Self
Wrapping (modular) addition. Computes self + rhs
, wrapping around at
the boundary of the type.
sourcepub fn checked_sub<T>(self, rhs: T) -> Option<Self>
pub fn checked_sub<T>(self, rhs: T) -> Option<Self>
Checked integer subtraction. Computes self - rhs
, returning None
if
overflow occurred.
sourcepub fn saturating_sub<T>(self, rhs: T) -> Self
pub fn saturating_sub<T>(self, rhs: T) -> Self
Saturating integer subtraction. Computes self - rhs
, saturating at the
numeric bounds instead of overflowing.
sourcepub fn overflowing_sub<T>(self, rhs: T) -> (Self, bool)
pub fn overflowing_sub<T>(self, rhs: T) -> (Self, bool)
Calculates self - rhs
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
sourcepub fn wrapping_sub<T>(self, rhs: T) -> Self
pub fn wrapping_sub<T>(self, rhs: T) -> Self
Wrapping (modular) subtraction. Computes self - rhs
, wrapping around at
the boundary of the type.
sourcepub fn checked_mul<T>(self, rhs: T) -> Option<Self>
pub fn checked_mul<T>(self, rhs: T) -> Option<Self>
Checked integer multiplication. Computes self * rhs
, returning None
if
overflow occurred.
sourcepub fn saturating_mul<T>(self, rhs: T) -> Self
pub fn saturating_mul<T>(self, rhs: T) -> Self
Saturating integer multiplication. Computes self * rhs
, saturating at the
numeric bounds instead of overflowing.
sourcepub fn overflowing_mul<T>(self, rhs: T) -> (Self, bool)
pub fn overflowing_mul<T>(self, rhs: T) -> (Self, bool)
Calculates self * rhs
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
sourcepub fn wrapping_mul<T>(self, rhs: T) -> Self
pub fn wrapping_mul<T>(self, rhs: T) -> Self
Wrapping (modular) multiplication. Computes self * rhs
, wrapping around at
the boundary of the type.
pub fn div_rem(self, other: Self) -> Result<(Self, Self), DivError>
source§impl u40
impl u40
sourcepub fn from_le_bytes(bytes: [u8; 5]) -> Self
pub fn from_le_bytes(bytes: [u8; 5]) -> Self
Create a native endian integer value from its representation as a byte array in little endian.
sourcepub fn to_le_bytes(self) -> [u8; 5]
pub fn to_le_bytes(self) -> [u8; 5]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub fn from_be_bytes(bytes: [u8; 5]) -> Self
pub fn from_be_bytes(bytes: [u8; 5]) -> Self
Create a native endian integer value from its representation as a byte array in big endian.
sourcepub fn to_be_bytes(self) -> [u8; 5]
pub 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 into_isize(self) -> isize
pub const fn into_isize(self) -> isize
Converts into isize
type.
sourcepub const fn into_usize(self) -> usize
pub const fn into_usize(self) -> usize
Converts into usize
type.
Trait Implementations§
source§impl<T> AddAssign<T> for u40
impl<T> AddAssign<T> for u40
source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+=
operation. Read moresource§impl<T> BitAndAssign<T> for u40
impl<T> BitAndAssign<T> for u40
source§fn bitand_assign(&mut self, rhs: T)
fn bitand_assign(&mut self, rhs: T)
&=
operation. Read moresource§impl<T> BitOrAssign<T> for u40
impl<T> BitOrAssign<T> for u40
source§fn bitor_assign(&mut self, rhs: T)
fn bitor_assign(&mut self, rhs: T)
|=
operation. Read moresource§impl<T> BitXorAssign<T> for u40
impl<T> BitXorAssign<T> for u40
source§fn bitxor_assign(&mut self, rhs: T)
fn bitxor_assign(&mut self, rhs: T)
^=
operation. Read moresource§impl<T> DivAssign<T> for u40
impl<T> DivAssign<T> for u40
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/=
operation. Read moresource§impl<T> MulAssign<T> for u40
impl<T> MulAssign<T> for u40
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*=
operation. Read moresource§impl Ord for u40
impl Ord for u40
source§impl PartialOrd for u40
impl PartialOrd for u40
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> RemAssign<T> for u40
impl<T> RemAssign<T> for u40
source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
%=
operation. Read moresource§impl<T> ShlAssign<T> for u40
impl<T> ShlAssign<T> for u40
source§fn shl_assign(&mut self, rhs: T)
fn shl_assign(&mut self, rhs: T)
<<=
operation. Read moresource§impl<T> ShrAssign<T> for u40
impl<T> ShrAssign<T> for u40
source§fn shr_assign(&mut self, rhs: T)
fn shr_assign(&mut self, rhs: T)
>>=
operation. Read moresource§impl<T> SubAssign<T> for u40
impl<T> SubAssign<T> for u40
source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read more