Jump to content

fast division method

- - - - -

  • Please log in to reply
No replies to this topic

#1
Guest_h4x_*

Guest_h4x_*
  • Guests
i am using this method:
shift divident 1 bit right, copmare memory region to wich i shift with divisor, is substraction possible do it. shift next bit, etc as long as i shift entire divident.

this method is slow.

i must implement power modulo (a^b%c).

how do i do it more efficiently?
i dont want any code just explain me it plz.
i know that GMH has mower modulo and its fast, so it is possible. i dont know if gmp use separate algo for powmod or its jsut fast multiplication/division.

im using this algo for powmod. division and multiplication is shift/add/sub.

def modexp ( t, u, n ):
s = 1
while u:
if u & 1:
s = (s * t)%n
u >>= 1
t = (t * t)%n;
return s


help me plz
if it does matter i write in asm, so im beyond limitations of languages.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users