Guest User

Untitled

a guest
May 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1. pub fn get_nth_zero(val: u8, n: u8) -> u8 {
  2. let mut x = val;
  3. for _ in 0..n {
  4. // makes the rightmost 0 bit a 1
  5. x |= x + 1;
  6. }
  7. (!x).trailing_zeros() as u8
  8. }
Add Comment
Please, Sign In to add comment