INNER CODE UNIT · Python
t
herumi/mcl · misc/mul-approx.py:55
t = 1<<(d+self.l-1)
(q, r) = divmod(t, self.p)
self.p0 = q
self.p1 = r
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)