pylab_ml.common.data.Parity
- Parity(data, even=True)[source]
Return the parity-bit from the data.
- eg. Parity(0b1011, even=True) -> 1
Parity(0b1011, even=False) -> 0 Parity(0b1101, even=True) -> 0
- Parameters:
data (int) – Input data for which the parity bit is to be calculated. The data should be a non negative integer.
even (bool, optional) – If True, calculate even parity; if False, calculate odd parity. Default is True.
- Returns:
Parity bit (0 or 1) based on the input data and parity type (even or odd).
- Return type:
int