INNER CODE UNIT · Python

check

herumi/mcl · misc/mul-approx.py:83

  def check(self, x):
    (x0, x1) = self.getTop(x)
    a = x.bit_length()
    (Q, R) = divmod(x, self.p)
    S = 1<<(2*self.d - (a - self.l + 1))
    (Q2, R2) = divmod(x0 * self.p0, S)
    lhs = S * self.p * (Q - Q2)
    rhs = S * x1 + self.p1 * x0 - S * R + self.p * R2
    if Q == Q2 or Q == Q2 + 1:
      return
    if Q != Q2:
      print('rare case')
      print(f'{x=}')
      print(f'{x0=}')
      print(f'{x1=}')
      print(f'{Q=}')
      print(f'{R=}')
      print(f'{Q2=}')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…