Created
March 29, 2018 04:00
-
-
Save kunigami/4989a15a9b7a47eb9e9b4516125be517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn first_non_zero_bit_position(input: u32) -> u32 { | |
let mut remaining: u32 = input; | |
let mut first_non_zero: u32 = 1; | |
while (remaining & 1) == 0 && remaining > 1 { | |
remaining /= 2; | |
first_non_zero += 1; | |
} | |
first_non_zero | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment