Function bitwise::word::count_leading_ones [] [src]

pub fn count_leading_ones<T: Word>(x: T) -> T

Count the number of leading ones in the binary representation of x.

Keywords:

Count leading ones.

Intrinsics:

  • ARMv8: cls.

Examples

use bitwise::word::*;

let n = 0b1111_1111_1100_1000u16;

assert_eq!(n.count_leading_ones(), 10);
assert_eq!(count_leading_ones(n), 10);