INNER CODE UNIT · Python
__str__
herumi/mcl · misc/mul-approx.py:60
def __str__(self):
return f'''p={self.p}
d={self.d}
l={self.l}
p0={self.p0}
p1={self.p1}'''
def getTop(self, x):
"""
return (x0, x1) such that x = x0 * 2**(a-d) + x1 where a = x.bit_length()
"""
if x < self.p:
return (0, x)
a = x.bit_length()
t = 1<<(a-self.d)
return divmod(x, t)
def quot(self, x):