extern crate int;
pub trait Base2: int::UInt {
fn floor_log2(self) -> u8 {
let r = Self::BIT_COUNT - (self.leading_zeros() as u8);
if r == 0 { 0 } else { r - 1 }
}
fn exp2(p: u8) -> Self { Self::_1 << p }
fn mask(p: u8) -> Self {
if p >= Self::BIT_COUNT { Self::MAX_VALUE } else { Self::exp2(p) - Self::_1 }
}
}
impl<T: int::UInt> Base2 for T {}