Function bitm::bits_to_store

source ·
pub fn bits_to_store<V: Into<u64>>(max_value: V) -> u8
Expand description

Calculates the minimal number of bits needed to store values from 0 to given max_value.

§Example

use bitm::bits_to_store;

assert_eq!(bits_to_store(0u8), 0);
assert_eq!(bits_to_store(1u16), 1);
assert_eq!(bits_to_store(7u32), 3);
assert_eq!(bits_to_store(8u64), 4);