BitFlagger (bit_flagger v0.1.0) View Source
A set of functions that manipulate bit flags.
Link to this section Summary
Functions
Turns off the flag at a specified index.
Checks if the flag is turned off at a specified index.
Turns on the flag at a specified index.
Checks if the flag is turned on at a specified index.
Converts an integer to a list of boolean values.
Link to this section Functions
Specs
off(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
Turns off the flag at a specified index.
Examples
iex> off(0b1111, 2)
0b1011
Specs
off?(non_neg_integer(), non_neg_integer()) :: boolean()
Checks if the flag is turned off at a specified index.
Examples
iex> off?(0b0001, 1)
true
iex> off?(0b0001, 0)
false
Specs
on(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
Turns on the flag at a specified index.
Examples
iex> on(0b0000, 2)
0b0100
Specs
on?(non_neg_integer(), non_neg_integer()) :: boolean()
Checks if the flag is turned on at a specified index.
Examples
iex> on?(0b0010, 1)
true
iex> on?(0b0010, 3)
false
Specs
parse(non_neg_integer(), non_neg_integer()) :: [boolean()]
Converts an integer to a list of boolean values.
Examples
iex> parse(0b1010, 4)
[false, true, false, true]