code cleanup
This commit is contained in:
parent
de5f5a70df
commit
6cda8bcfa0
|
@ -11,35 +11,12 @@ al = align_binary_to_right
|
|||
def multiply(x, y, method):
|
||||
if method == 4:
|
||||
n = len(bin(x)[2:]) # base registry bit length, usually written as n
|
||||
|
||||
# every table line has registers like so: RG1, RG3, RG2
|
||||
data_table = [[["0"*(2*n+1), "0" + bin(y)[2:] + "0"*n, bin(x)[2:], "-"]]*2]
|
||||
print(f"Starting with: {data_table}")
|
||||
print(data_table[-1][-1][2])
|
||||
print(int('0b' + data_table[-1][-1][2], 2))
|
||||
|
||||
while int('0b' + data_table[-1][-1][2], 2) != 0:
|
||||
data_table.append([])
|
||||
'''
|
||||
if data_table[-2][-1][2][0] == "1":
|
||||
data_table[-1].append([
|
||||
al(bin(int("0b"+data_table[-2][-1][0], 2) + int("0b"+data_table[-2][-1][1], 2))[-(2*n+1):], 2*n+1), # RG1 + RG3
|
||||
data_table[-2][-1][1],
|
||||
data_table[-2][-1][2],
|
||||
])
|
||||
|
||||
data_table[-1].append([
|
||||
data_table[-1][-1][0],
|
||||
'0' + data_table[-1][-1][1][:-1], # 0.r(RG3)
|
||||
data_table[-2][-1][2][1:] + '0', # l(RG2).0
|
||||
])
|
||||
'''
|
||||
|
||||
'''
|
||||
if data_table[-2][-1][2][0] == "1":
|
||||
data_table[-1].append([
|
||||
al(bin(int("0b"+data_table[-2][-1][0], 2) + int("0b"+data_table[-2][-1][1], 2))[-(2*n+1):], 2*n+1), # RG1 + RG3
|
||||
'0' + data_table[-2][1][:-1],
|
||||
data_table[-2][2][1:] + '0', # l(RG2).0
|
||||
'''
|
||||
|
||||
if data_table[-2][-1][2][0] == "1":
|
||||
data_table[-1].append([
|
||||
|
@ -64,9 +41,6 @@ def multiply(x, y, method):
|
|||
"0.r(RG3), l(RG2).0"
|
||||
])
|
||||
|
||||
|
||||
print(data_table)
|
||||
|
||||
return data_table
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue