cnfy-uint 0.2.3

Zero-dependency 256-bit unsigned integer arithmetic for cryptographic applications
Documentation
//! 384-bit unsigned integer type stored as six `u64` limbs in little-endian
//! order: `[w0, w1, w2, w3, w4, w5]` where `w0` is the least significant.

/// A 384-bit unsigned integer represented as six 64-bit limbs in little-endian
/// order.
///
/// The internal layout is `[w0, w1, w2, w3, w4, w5]` where `w0` contains the
/// least significant 64 bits and `w5` contains the most significant 64 bits.
/// Used for intermediate results in multi-precision arithmetic.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct U384(pub(crate) [u64; 6]);

impl PartialOrd for U384 {
    #[inline]
    fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for U384 {
    #[inline]
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
        self.0[5]
            .cmp(&other.0[5])
            .then(self.0[4].cmp(&other.0[4]))
            .then(self.0[3].cmp(&other.0[3]))
            .then(self.0[2].cmp(&other.0[2]))
            .then(self.0[1].cmp(&other.0[1]))
            .then(self.0[0].cmp(&other.0[0]))
    }
}

mod constants;
mod from_be_bytes;
mod from_be_limbs;
mod from_le_bytes;
mod from_le_limbs;
mod to_be_bytes;
mod to_be_limbs;
mod to_le_bytes;
mod to_le_limbs;

mod bit_len;
mod checked_add;
mod checked_sub;
mod const_eq;
mod div_u64;
mod is_even;
mod is_odd;
mod is_zero;
mod leading_zero_bytes;
mod leading_zeros;
mod low_u256;
mod negate;
mod non_zero;
mod overflowing_add;
mod overflowing_sub;
mod shl_bits;
mod shr_bits;
mod sig_limbs;
mod trailing_zeros;

// Standard trait implementations
mod add;
mod bitand;
mod bitor;
mod bitxor;
mod default;
mod display;
mod from_limbs;
mod from_str;
mod from_u128;
mod from_u256;
mod from_u320;
mod from_u64;
mod into_be_bytes;
mod into_limbs;
mod lower_hex;
mod not;
mod shl;
mod shr;
mod sub;
mod upper_hex;