Function mayda::utility::words_for_bits [] [src]

pub fn words_for_bits(bits: u32) -> usize

Returns number of words required to store the given number of bits. A word is 32 bits long.

Panics

Integer overflow occurs when the value of bits is above u32::MAX - 31. This should not happen in mayda since this function is only used to find the number of words required for an encoded block of up to 128 integers.

Examples

use std::mem;
use mayda::utility::words_for_bits;
 
let words = words_for_bits(13 * (mem::size_of::<u8>() * 8) as u32);
assert_eq!(4, words);