mod to symmetric range

Torbjorn Granlund tg at gmplib.org
Sun Sep 5 20:52:14 CEST 2010


Roman Pearce <rpearcea at cecm.sfu.ca> writes:

  I'm trying to efficiently compute r = a mod b with
  -(b-1)/2 <= r <= b/2.  Any suggestions?  All of my
  solutions move too much data around.
  
Is each b invvarint over several reductions?
Then pre-computing b/2 (using a 2exp function) will help.

-- 
Torbjörn


More information about the gmp-discuss mailing list