Struct kaspa_math::Uint256
source · pub struct Uint256(pub [u64; 4]);Expand description
Little-endian large integer type
Tuple Fields§
§0: [u64; 4]Implementations§
source§impl Uint256
impl Uint256
pub const ZERO: Self = _
pub const MIN: Self = Self::ZERO
pub const MAX: Self = _
pub const BITS: u32 = 256u32
pub const BYTES: usize = 32usize
pub const LIMBS: usize = 4usize
pub fn from_u64(n: u64) -> Self
pub fn from_u128(n: u128) -> Self
pub fn as_u128(self) -> u128
pub fn as_u64(self) -> u64
pub fn is_zero(self) -> bool
pub fn leading_zeros(&self) -> u32
pub fn overflowing_shl(self, s: u32) -> (Self, bool)
pub fn wrapping_shl(self, s: u32) -> Self
pub fn overflowing_shr(self, s: u32) -> (Self, bool)
pub fn overflowing_add(self, other: Self) -> (Self, bool)
pub fn overflowing_add_u64(self, other: u64) -> (Self, bool)
pub fn overflowing_sub(self, other: Self) -> (Self, bool)
sourcepub fn overflowing_mul_u64(self, other: u64) -> (Self, bool)
pub fn overflowing_mul_u64(self, other: u64) -> (Self, bool)
Multiplication by u64
pub fn carrying_mul_u64(self, other: u64) -> (Self, u64)
pub fn overflowing_mul(self, other: Self) -> (Self, bool)
sourcepub fn from_le_bytes(bytes: [u8; 32]) -> Self
pub fn from_le_bytes(bytes: [u8; 32]) -> Self
Creates big integer value from a byte slice using little-endian encoding
sourcepub fn from_be_bytes(bytes: [u8; 32]) -> Self
pub fn from_be_bytes(bytes: [u8; 32]) -> Self
Creates big integer value from a byte slice using big-endian encoding
sourcepub fn to_le_bytes(self) -> [u8; 32]
pub fn to_le_bytes(self) -> [u8; 32]
Convert’s the Uint into little endian byte array
sourcepub fn to_be_bytes(self) -> [u8; 32]
pub fn to_be_bytes(self) -> [u8; 32]
Convert’s the Uint into big endian byte array
pub fn to_be_bytes_var(self) -> Vec<u8>
pub fn div_rem_u64(self, other: u64) -> (Self, u64)
pub fn as_f64(&self) -> f64
pub fn div_rem(self, other: Self) -> (Self, Self)
sourcepub fn mod_inverse(self, prime: Self) -> Option<Self>
pub fn mod_inverse(self, prime: Self) -> Option<Self>
Assumes self < prime
pub fn iter_be_bits(self) -> impl ExactSizeIterator<Item = bool> + FusedIterator
sourcepub fn from_hex(hex: &str) -> Result<Self, Error>
pub fn from_hex(hex: &str) -> Result<Self, Error>
Converts a Self::BYTES*2 hex string interpreted as big endian, into a Uint
pub fn from_be_bytes_var(bytes: &[u8]) -> Result<Self, TryFromSliceError>
source§impl Uint256
impl Uint256
pub fn from_compact_target_bits(bits: u32) -> Self
sourcepub fn compact_target_bits(self) -> u32
pub fn compact_target_bits(self) -> u32
Computes the target value in float format from BigInt format.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Uint256
impl<'de> Deserialize<'de> for Uint256
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Uint256
impl Ord for Uint256
source§impl PartialEq<Uint256> for Uint256
impl PartialEq<Uint256> for Uint256
source§impl PartialEq<u128> for Uint256
impl PartialEq<u128> for Uint256
source§impl PartialOrd<Uint256> for Uint256
impl PartialOrd<Uint256> for Uint256
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl PartialOrd<u128> for Uint256
impl PartialOrd<u128> for Uint256
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl PartialOrd<u64> for Uint256
impl PartialOrd<u64> for Uint256
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more