AritmeticLogic¶
- class chepy.modules.aritmeticlogic.AritmeticLogic(*data)¶
- add(n: int) AritmeticLogicT ¶
Add a number to the state
- Parameters
n (int) – Number to add with. Can be decimal or hex string without 0x
- Returns
The Chepy object.
- Return type
- addition(delimiter=None) AritmeticLogicT ¶
Adds a list of numbers. If an item in the string is not a number it is excluded from the list.
- Parameters
delimiter (str, optional) – Delimiter. Defaults to None.
- Returns
The Chepy object.
- Return type
- bit_shift_left(amount: int = 1)¶
Shifts each byte in the input byte array to the left by a specified amount.
- Parameters
amount (int, optional) – Amount. Defaults to 1.
- Returns
The Chepy object.
- Return type
- bit_shift_right(amount: int = 1, operation_type: Literal['logical', 'arithmetic'] = 'logical') AritmeticLogicT ¶
Shifts the bits in each byte towards the right by the specified amount.
- Parameters
amount (int, optional) – Amount. Defaults to 1
operation_type (Literal['logical', 'arithmetic'], optional) – Operation type. Defaults to ‘logical’.
- Returns
The Chepy object.
- Return type
- divide(n: int) AritmeticLogicT ¶
Divide a number to the state. Chepy is not optimized for float math. Subsequent methods may fail.
- Parameters
n (int) – Number to divide with
- Returns
The Chepy object.
- Return type
- int_to_base(base: Union[int, str]) AritmeticLogicT ¶
Convert the state to a different base
- Parameters
base (int) – Base to convert to
- Returns
The Chepy object.
- Return type
- mean() AritmeticLogicT ¶
Calculate the mean of the state
- Returns
The Chepy object.
- Return type
- median() AritmeticLogicT ¶
Calculate the median of the state
- Returns
The Chepy object.
- Return type
- multiply(n: int) AritmeticLogicT ¶
Multiply a number to the state
- Parameters
n (int) – Number to multiply with
- Returns
The Chepy object.
- Return type
- power(n: int) AritmeticLogicT ¶
Convert state to the n power of
- Parameters
n (int) – Exponent
- Returns
The Chepy object.
- Return type
- sub(n: int) AritmeticLogicT ¶
SUB the input with the given key
- Parameters
n (int) – Number to subtract with
- Returns
The Chepy object.
- Return type
- subtract(delimiter=None) AritmeticLogicT ¶
Subtracts a list of numbers. If an item in the string is not a number it is excluded from the list.
- Parameters
delimiter (str, optional) – Delimiter. Defaults to None.
- Returns
The Chepy object.
- Return type