Function bitfrob::u128_get_value
source · pub const fn u128_get_value(low: u32, high: u32, u: u128) -> u128Expand description
Get the low to high bit region of u, down shifted by low.
The low and high values form an inclusive bit range.
The output is down shifted by low bits so that it will be based at 0.
Panics
lowandhighcan’t exceed the number of bits in the type.lowmust be less thanhigh.
assert_eq!(u128_get_value(0, 2, u128::MAX), 0b0000_0111_u128);
assert_eq!(u128_get_value(1, 3, u128::MAX), 0b0000_0111_u128);
assert_eq!(u128_get_value(4, 7, u128::MAX), 0b0000_1111_u128);