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

Link to this section Functions

Specs

off(state(), index()) :: state()

Turns off the flag at a specified index.

Examples

iex> off(0b1111, 2)
0b1011

iex> off(<<0b1111>>, 2)
<<0b1011>>

Specs

off?(state(), index()) :: boolean()

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

on(state(), index()) :: state()

Turns on the flag at a specified index.

Examples

iex> on(0b0000, 2)
0b0100

iex> on(<<0b0000>>, 2)
<<0b0100>>

Specs

on?(state(), index()) :: boolean()

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]