BitFlagger (bit_flagger v0.1.1) 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 state to a list of boolean values.
Link to this section Types
Specs
index() :: non_neg_integer()
Specs
state() :: non_neg_integer() | binary()
Link to this section Functions
Specs
Turns off the flag at a specified index.
Examples
iex> off(0b1111, 2)
0b1011
iex> off(<<0b1111>>, 2)
<<0b1011>>
Specs
Checks if the flag is turned off at a specified index.
Examples
iex> off?(0b0001, 1)
true
iex> off?(0b0001, 0)
false
iex> off?(<<0b0001>>, 1)
true
iex> off?(<<0b0001>>, 0)
false
Specs
Turns on the flag at a specified index.
Examples
iex> on(0b0000, 2)
0b0100
iex> on(<<0b0000>>, 2)
<<0b0100>>
Specs
Checks if the flag is turned on at a specified index.
Examples
iex> on?(0b0010, 1)
true
iex> on?(0b0010, 3)
false
iex> on?(<<0b0010>>, 1)
true
iex> on?(<<0b0010>>, 3)
false
Specs
parse(state(), pos_integer()) :: [boolean()]
Converts state to a list of boolean values.
Examples
iex> parse(0b1010, 4)
[false, true, false, true]
iex> parse(<<0b1010>>, 4)
[false, true, false, true]