pylab_ml.common.data.complement2

complement2(value, bits)[source]

2’s complement representation from a value with number of bits.

eg. complement2(0, 8) -> 0

complement2(1, 8) -> 1 complement2(-1, 8) -> 255 complement2(33, 16) -> 223

Parameters:
  • value (int) – Integer value to be converted to 2’s complement.

  • bits (int) – Number of bits for the 2’s complement representation.

Returns:

2’s complement representation of the value.

Return type:

int