ds: 1e: karatsuba prototype
This commit is contained in:
17
ds/25-1/1e/test.py
Normal file
17
ds/25-1/1e/test.py
Normal 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)))
|
||||
Reference in New Issue
Block a user