fix BasicRegister shrinking
This commit is contained in:
parent
8f68099309
commit
f2ee4cd709
|
@ -27,7 +27,7 @@ class BasicRegister:
|
|||
"""
|
||||
current_memory_size: int = len(self.memory)
|
||||
return BasicRegister(
|
||||
[False] * max(resulting_size - current_memory_size, 0) + list(self.memory)[-current_memory_size:]
|
||||
[False] * max(resulting_size - current_memory_size, 0) + list(self.memory)[-resulting_size:]
|
||||
)
|
||||
|
||||
def reverse(self):
|
||||
|
@ -87,7 +87,7 @@ def binary_sum(a_original: BasicRegister, b_original: BasicRegister) -> BasicReg
|
|||
c = BasicRegister([False] * required_size)
|
||||
|
||||
carry = False
|
||||
for i in range(size_a - 1, 0, -1):
|
||||
for i in range(required_size - 1, 0, -1):
|
||||
current_bit_sum = a.memory[i] + b.memory[i] + carry
|
||||
carry = bool(current_bit_sum & 2)
|
||||
c.memory[i] = bool(current_bit_sum & 1)
|
||||
|
|
Loading…
Reference in New Issue