diff --git a/bitutilities.py b/bitutilities.py index 5a015f5..052163e 100644 --- a/bitutilities.py +++ b/bitutilities.py @@ -10,12 +10,17 @@ class BasicRegister: """ def __init__(self, memory: list[bool]): - """Constructor method""" self.memory: deque[bool] = deque(memory) + def __repr__(self) -> str: + return f"Memory: {[int(value) for value in self.memory]}" + def __str__(self) -> str: return f"Memory: {[int(value) for value in self.memory]}" + def __len__(self) -> int: + return len(self.memory) + def adjusted_by_size(self, resulting_size: int) -> Self: """ Adjusts a register to a given size. @@ -72,8 +77,8 @@ def binary_sum(a_original: BasicRegister, b_original: BasicRegister) -> BasicReg :return: Register containing the sum. :rtype: BasicRegister """ - size_a = len(a_original.memory) - size_b = len(b_original.memory) + size_a = len(a_original) + size_b = len(b_original) required_size = max(size_a, size_b)