ilog2 0.2.0

Integer logarithm library including some bit operations.
Documentation

#Integer Logarithm Library for Rust

##API List

  1. roundup_pow2(x), rounddown_pow2(x) for u8 ... u64, returns same integer type.
  2. bit_length<u8 ... u64>(), returns usize
  3. bit_mask<u8 ... u64>(), returns self-typed 0xFF...FF
  4. msb(x), lsb(x), msz(x), lsz(x) for u8 ... u64, returns i8, -1i8 on error. Index starts from 0.
  5. ffs(x), fls(x), ffz(x), flz(x) for u8 ... u64, returns u8, 0u8 means error. Index starts from 1.
  • msb: Find first 1 bit from msb position. Return its index (index starts from lsb).
  • lsb: Find first 1 bit from lsb position. Return its index (index starts from lsb).
  • msz, lsz: Find 0 like above.
  • ffs, fls, ffz, flz: +1 to lsb, msb, lsz, msz