Skip to content

komm.int2binlist

Converts an integer to its bit array representation (LSB first).

Parameters:

  • integer (int)

    The input integer. May be any nonnegative integer.

  • width (Optional[int])

    If this parameter is specified, the output will be filled with zeros on the right so that its length will be the specified value.

Returns:

  • binlist (Array1D[int])

    An array of $0$'s and $1$'s whose $i$-th element stands for the coefficient of $2^i$ in the binary representation of the input integer.

Examples:

>>> komm.int2binlist(16)
array([0, 0, 0, 0, 1])
>>> komm.int2binlist(26)
array([0, 1, 0, 1, 1])
>>> komm.int2binlist(26, width=8)
array([0, 1, 0, 1, 1, 0, 0, 0])