Random stuff, testing things, and so on.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

11 lines
271 B

fn count(bits: usize) -> u32 {
let num_bits = usize::BITS;
num_bits as u32 - bits.leading_zeros() + 1
}
fn main() {
println!("{}", count(0b111));
println!("{}", count(0b1111_1111));
println!("{}", count(64)); // 1000000
println!("{}", 1 >> 1);
}