Skip to main content

Module bitlen

Module bitlen 

Source
Expand description

Bit calculations.

These provide a single place to handle bits-to-bytes conversions and the u32/usize discrepancy that can only be solved by panics or casting.

Functionsยง

from_bytes ๐Ÿ”’
Calculate a u32 representing a number of bits from the given number of bytes as a usize.
from_limbs ๐Ÿ”’
Calculate a u32 representing a number of bits in an integer with the given number of limbs.
mul ๐Ÿ”’
to_bytes ๐Ÿ”’
Calculate a usize representing the number of bytes required to store the given number of bits represented as a u32 (i.e. rounding up).
to_limbs ๐Ÿ”’
Calculate a usize representing the number of limbs required to store the given number of bits represented as a u32 (i.e. rounding up).
u32_to_usize ๐Ÿ”’
usize_to_u32 ๐Ÿ”’