checksum v0.1.0 Checksum.Helpers
Summary
Functions
Calculates a bit mask of ones with a length of width
Reorder the bits of a binary sequence value, by reflecting them about the middle position
Conditional Reorder the bits of a binary sequence, by reflecting them about the middle position.
If bool is true the bits will be reflected, if it is false the input value will be returned
Calculates a top bit mask
Functions
Calculates a bit mask of ones with a length of width.
Examples
iex> Checksum.Helpers.bits_mask(1) |> Integer.to_charlist(2)
'1'
iex> Checksum.Helpers.bits_mask(4) |> Integer.to_charlist(2)
'1111'
iex> Checksum.Helpers.bits_mask(8) |> Integer.to_charlist(2)
'11111111'
Reorder the bits of a binary sequence value, by reflecting them about the middle position.
Examples
iex> Checksum.Helpers.reflect(0x3E23, 3) == 0x3E26
true
Conditional Reorder the bits of a binary sequence, by reflecting them about the middle position.
If bool is true the bits will be reflected, if it is false the input value will be returned.
Examples
iex> Checksum.Helpers.reflect(0x3E23, 3, true) == 0x3E26
true
iex> Checksum.Helpers.reflect(0x3E23, 3, false) == 0x3E23
true