//! 320-bit unsigned integer type stored as five `u64` limbs in little-endian
//! order: `[w0, w1, w2, w3, w4]` where `w0` is the least significant.

/// A 320-bit unsigned integer represented as five 64-bit limbs in little-endian
/// order.
///
/// The internal layout is `[w0, w1, w2, w3, w4]` where `w0` contains the least
/// significant 64 bits and `w4` contains the most significant 64 bits.
/// Used for intermediate results in multi-precision arithmetic (e.g. scalar
/// multiplication producing a 5-limb product).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct U320(pub(crate) [u64; 5]);

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

impl Ord for U320 {
    #[inline]
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
        // Compare from MSB (index 4) to LSB (index 0) for correct numerical ordering.
        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]))
    }
}

// Constants
mod constants;

// Construction
mod from_be_bytes;
mod from_be_limbs;
mod from_le_bytes;
mod from_le_limbs;
mod from_str;
mod from_u128;
mod from_u256;
mod from_u64;

// Conversion
mod into_be_bytes;
mod low_u256;
mod to_be_bytes;
mod to_be_limbs;
mod to_le_bytes;
mod to_le_limbs;

// Inspection
mod bit_len;
mod const_eq;
mod is_even;
mod is_odd;
mod is_zero;
mod leading_zero_bytes;
mod leading_zeros;
mod non_zero;
mod sig_limbs;
mod trailing_zeros;

// Arithmetic
mod add;
mod checked_add;
mod checked_sub;
mod div_u64;
mod negate;
mod overflowing_add;
mod overflowing_sub;
mod sub;

// Bitwise
mod bitand;
mod bitor;
mod bitxor;
mod not;

// Shifts
mod shl;
mod shl_bits;
mod shr;
mod shr_bits;

// Standard trait implementations
mod default;
mod display;
mod from_limbs;
mod into_limbs;
mod lower_hex;
mod upper_hex;
