ds: 1e: karatsuba prototype

This commit is contained in:
2025-12-15 18:53:54 +03:00
parent 3a425db8b4
commit 9c8d3a7b5f
3 changed files with 227 additions and 24 deletions

17
ds/25-1/1e/test.py Normal file
View File

@ -0,0 +1,17 @@
U8_MAX = 0xFFFFFFFFFFFFFFFF
U16_MAX = U8_MAX << 64 | U8_MAX
U32_MAX = U16_MAX << 128 | U16_MAX
def dothex(num):
strhex = hex(num)[2:]
dothex = strhex[-16:]
strhex = strhex[:-16]
while len(strhex) > 0:
dothex = strhex[-16:] + '.' + dothex
strhex = strhex[:-16]
return '0x' + dothex
print('mul16', dothex(U16_MAX * 2 % (U16_MAX + 1)))
print('mul32', dothex(U32_MAX * U16_MAX % (U32_MAX + 1)))