//! Extraction of the low 128 bits from a [`U256`].
use super::U256;
impl U256 {
/// Returns the low (least significant) 128-bit value, reconstructed from
/// the two least significant 64-bit limbs (`w2` and `w3`).
///
/// # Examples
///
/// ```
/// use cnfy_uint::u256::U256;
///
/// let v = U256::from_be_limbs([0, 42, 0, 7]);
/// assert_eq!(v.low_u128(), 7);
/// ```
#[inline]
pub const fn low_u128(&self) -> u128 {
(self.0[1] as u128) << 64 | self.0[0] as u128
}
}
#[cfg(test)]
mod ai_tests {
use super::*;
/// Low value is reconstructed from limbs w2 and w3.
#[test]
fn returns_low() {
let v = U256::from_be_limbs([0, 0xAB, 0, 0xCD]);
assert_eq!(v.low_u128(), 0xCD);
}
}