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

Chepy

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

Chepy

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

Chepy

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

Chepy

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

Chepy

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

Chepy

mean() AritmeticLogicT

Calculate the mean of the state

Returns

The Chepy object.

Return type

Chepy

median() AritmeticLogicT

Calculate the median of the state

Returns

The Chepy object.

Return type

Chepy

multiply(n: int) AritmeticLogicT

Multiply a number to the state

Parameters

n (int) – Number to multiply with

Returns

The Chepy object.

Return type

Chepy

power(n: int) AritmeticLogicT

Convert state to the n power of

Parameters

n (int) – Exponent

Returns

The Chepy object.

Return type

Chepy

sub(n: int) AritmeticLogicT

SUB the input with the given key

Parameters

n (int) – Number to subtract with

Returns

The Chepy object.

Return type

Chepy

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

Chepy

sum() AritmeticLogicT

Calculate the sum of the state

Returns

The Chepy object.

Return type

Chepy