sweetpea.core.binary module

This module provides aliases for values used in representing numbers in a binary format.

sweetpea.core.binary.BinaryNumber

A representation of a binary number as a list of integers, where each element of the list is either 1 or -1.

alias of List[int]

sweetpea.core.binary.int_to_binary(value)

Converts an integer value to binary where the output representation is a list of binary digits of the alphabet {-1, 1} (i.e., similar to a normal binary representation except the “false” value is -1 instead of 0).

For example:

Decimal

int_to_binary

Binary

2

[1, -1]

0b10

11

[1, -1, 1, 1]

0b1011

Parameters

value (int) –

Return type

List[int]