Struct radix_engine_common::math::bnum_integer::U512
source · #[repr(transparent)]pub struct U512(pub BUint<8>);
Expand description
Provides safe integer arithmetic.
Operations like +
, ‘-’, ‘*’, or ‘/’ sometimes produce overflow
which is detected and results in a panic, in of silently
wrapping around.
The bit length of output type will be the greater one in the math operation, and if any of the types was signed, then the resulting type will be signed too, otherwise the output type is unsigned.
The underlying value can be retrieved through the .0
index of the
U512
tuple.
§Layout
U512
will have the same methods and traits as
the built-in counterpart.
Tuple Fields§
§0: BUint<8>
Implementations§
source§impl U512
impl U512
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of self
.
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representation of self
.
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representation of self
.
sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the bit pattern of the integer.
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary representation of self
.
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.
source§impl U512
impl U512
pub fn is_power_of_two(self) -> bool
pub fn next_power_of_two(self) -> Self
Trait Implementations§
source§impl Add<PreciseDecimal> for U512
impl Add<PreciseDecimal> for U512
§type Output = PreciseDecimal
type Output = PreciseDecimal
+
operator.source§impl Add<U512> for PreciseDecimal
impl Add<U512> for PreciseDecimal
source§impl AddAssign<&U512> for U512
impl AddAssign<&U512> for U512
source§fn add_assign(&mut self, other: &U512)
fn add_assign(&mut self, other: &U512)
+=
operation. Read moresource§impl AddAssign<U512> for Decimal
impl AddAssign<U512> for Decimal
source§fn add_assign(&mut self, other: U512)
fn add_assign(&mut self, other: U512)
+=
operation. Read moresource§impl AddAssign<U512> for PreciseDecimal
impl AddAssign<U512> for PreciseDecimal
source§fn add_assign(&mut self, other: U512)
fn add_assign(&mut self, other: U512)
+=
operation. Read moresource§impl AddAssign for U512
impl AddAssign for U512
source§fn add_assign(&mut self, other: U512)
fn add_assign(&mut self, other: U512)
+=
operation. Read moresource§impl BitAndAssign for U512
impl BitAndAssign for U512
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
&=
operation. Read moresource§impl BitOrAssign for U512
impl BitOrAssign for U512
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
|=
operation. Read moresource§impl BitXorAssign for U512
impl BitXorAssign for U512
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
^=
operation. Read moresource§impl CheckedAdd<Decimal> for U512
impl CheckedAdd<Decimal> for U512
source§impl CheckedAdd<PreciseDecimal> for U512
impl CheckedAdd<PreciseDecimal> for U512
type Output = PreciseDecimal
fn checked_add(self, other: PreciseDecimal) -> Option<Self::Output>
source§impl CheckedAdd<U512> for Decimal
impl CheckedAdd<U512> for Decimal
source§impl CheckedAdd<U512> for PreciseDecimal
impl CheckedAdd<U512> for PreciseDecimal
type Output = PreciseDecimal
fn checked_add(self, other: U512) -> Option<Self::Output>
source§impl CheckedAdd for U512
impl CheckedAdd for U512
source§impl CheckedDiv<Decimal> for U512
impl CheckedDiv<Decimal> for U512
source§impl CheckedDiv<PreciseDecimal> for U512
impl CheckedDiv<PreciseDecimal> for U512
type Output = PreciseDecimal
fn checked_div(self, other: PreciseDecimal) -> Option<Self::Output>
source§impl CheckedDiv<U512> for Decimal
impl CheckedDiv<U512> for Decimal
source§impl CheckedDiv<U512> for PreciseDecimal
impl CheckedDiv<U512> for PreciseDecimal
type Output = PreciseDecimal
fn checked_div(self, other: U512) -> Option<Self::Output>
source§impl CheckedDiv for U512
impl CheckedDiv for U512
source§impl CheckedMul<Decimal> for U512
impl CheckedMul<Decimal> for U512
source§impl CheckedMul<PreciseDecimal> for U512
impl CheckedMul<PreciseDecimal> for U512
type Output = PreciseDecimal
fn checked_mul(self, other: PreciseDecimal) -> Option<Self::Output>
source§impl CheckedMul<U512> for Decimal
impl CheckedMul<U512> for Decimal
source§impl CheckedMul<U512> for PreciseDecimal
impl CheckedMul<U512> for PreciseDecimal
type Output = PreciseDecimal
fn checked_mul(self, other: U512) -> Option<Self::Output>
source§impl CheckedMul for U512
impl CheckedMul for U512
source§impl CheckedSub<Decimal> for U512
impl CheckedSub<Decimal> for U512
source§impl CheckedSub<PreciseDecimal> for U512
impl CheckedSub<PreciseDecimal> for U512
type Output = PreciseDecimal
fn checked_sub(self, other: PreciseDecimal) -> Option<Self::Output>
source§impl CheckedSub<U512> for Decimal
impl CheckedSub<U512> for Decimal
source§impl CheckedSub<U512> for PreciseDecimal
impl CheckedSub<U512> for PreciseDecimal
type Output = PreciseDecimal
fn checked_sub(self, other: U512) -> Option<Self::Output>
source§impl CheckedSub for U512
impl CheckedSub for U512
source§impl Div<PreciseDecimal> for U512
impl Div<PreciseDecimal> for U512
§type Output = PreciseDecimal
type Output = PreciseDecimal
/
operator.source§impl Div<U512> for PreciseDecimal
impl Div<U512> for PreciseDecimal
source§impl DivAssign<&U512> for U512
impl DivAssign<&U512> for U512
source§fn div_assign(&mut self, other: &U512)
fn div_assign(&mut self, other: &U512)
/=
operation. Read moresource§impl DivAssign<U512> for Decimal
impl DivAssign<U512> for Decimal
source§fn div_assign(&mut self, other: U512)
fn div_assign(&mut self, other: U512)
/=
operation. Read moresource§impl DivAssign<U512> for PreciseDecimal
impl DivAssign<U512> for PreciseDecimal
source§fn div_assign(&mut self, other: U512)
fn div_assign(&mut self, other: U512)
/=
operation. Read moresource§impl DivAssign for U512
impl DivAssign for U512
source§fn div_assign(&mut self, other: U512)
fn div_assign(&mut self, other: U512)
/=
operation. Read moresource§impl FromPrimitive for U512
impl FromPrimitive for U512
source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§impl Mul<PreciseDecimal> for U512
impl Mul<PreciseDecimal> for U512
§type Output = PreciseDecimal
type Output = PreciseDecimal
*
operator.source§impl Mul<U512> for PreciseDecimal
impl Mul<U512> for PreciseDecimal
source§impl MulAssign<&U512> for U512
impl MulAssign<&U512> for U512
source§fn mul_assign(&mut self, other: &U512)
fn mul_assign(&mut self, other: &U512)
*=
operation. Read moresource§impl MulAssign<U512> for Decimal
impl MulAssign<U512> for Decimal
source§fn mul_assign(&mut self, other: U512)
fn mul_assign(&mut self, other: U512)
*=
operation. Read moresource§impl MulAssign<U512> for PreciseDecimal
impl MulAssign<U512> for PreciseDecimal
source§fn mul_assign(&mut self, other: U512)
fn mul_assign(&mut self, other: U512)
*=
operation. Read moresource§impl MulAssign for U512
impl MulAssign for U512
source§fn mul_assign(&mut self, other: U512)
fn mul_assign(&mut self, other: U512)
*=
operation. Read moresource§impl Ord for U512
impl Ord for U512
source§impl PartialEq for U512
impl PartialEq for U512
source§impl PartialOrd for U512
impl PartialOrd for U512
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 RemAssign<&U512> for U512
impl RemAssign<&U512> for U512
source§fn rem_assign(&mut self, other: &U512)
fn rem_assign(&mut self, other: &U512)
%=
operation. Read moresource§impl RemAssign for U512
impl RemAssign for U512
source§fn rem_assign(&mut self, other: U512)
fn rem_assign(&mut self, other: U512)
%=
operation. Read moresource§impl ShlAssign<u32> for U512
impl ShlAssign<u32> for U512
source§fn shl_assign(&mut self, other: u32)
fn shl_assign(&mut self, other: u32)
<<=
operation. Read moresource§impl ShrAssign<u32> for U512
impl ShrAssign<u32> for U512
source§fn shr_assign(&mut self, other: u32)
fn shr_assign(&mut self, other: u32)
>>=
operation. Read moresource§impl Sub<PreciseDecimal> for U512
impl Sub<PreciseDecimal> for U512
§type Output = PreciseDecimal
type Output = PreciseDecimal
-
operator.source§impl Sub<U512> for PreciseDecimal
impl Sub<U512> for PreciseDecimal
source§impl SubAssign<&U512> for U512
impl SubAssign<&U512> for U512
source§fn sub_assign(&mut self, other: &U512)
fn sub_assign(&mut self, other: &U512)
-=
operation. Read moresource§impl SubAssign<U512> for Decimal
impl SubAssign<U512> for Decimal
source§fn sub_assign(&mut self, other: U512)
fn sub_assign(&mut self, other: U512)
-=
operation. Read moresource§impl SubAssign<U512> for PreciseDecimal
impl SubAssign<U512> for PreciseDecimal
source§fn sub_assign(&mut self, other: U512)
fn sub_assign(&mut self, other: U512)
-=
operation. Read moresource§impl SubAssign for U512
impl SubAssign for U512
source§fn sub_assign(&mut self, other: U512)
fn sub_assign(&mut self, other: U512)
-=
operation. Read moresource§impl ToPrimitive for U512
impl ToPrimitive for U512
source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self
to a u128
. If the value cannot be
represented by a u128
(u64
under the default implementation), then
None
is returned. Read moresource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moresource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.source§impl TryFrom<U512> for PreciseDecimal
impl TryFrom<U512> for PreciseDecimal
impl Copy for U512
impl Eq for U512
Auto Trait Implementations§
impl RefUnwindSafe for U512
impl Send for U512
impl Sync for U512
impl Unpin for U512
impl UnwindSafe for U512
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read moresource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.