Bit Operations
fn kth_bit<T>(x: T, k: usize) -> T
where
T: std::ops::BitAnd<Output=T> + std::ops::Shr<usize, Output=T> + From<u8>,
{
(x >> k) & T::from(1)
}
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
fn kth_bit<T>(x: T, k: usize) -> T
where
T: std::ops::BitAnd<Output=T> + std::ops::Shr<usize, Output=T> + From<u8>,
{
(x >> k) & T::from(1)
}