query: nearest integer divide

Torbjorn Granlund tege@swox.com
24 Mar 2003 13:13:17 +0100


Carl Devore <devore@math.udel.edu> writes:

  This, and the previous ideas in this thread, seem unnecessarily
  complicated to me.  We want to divide x by 2^p and round the
  result to the nearest integer.  Can't we just do this: truncate p bits
  from x.  If the last bit truncated was a 1, then add 1 to the result (or
  subtract 1 if it was negative).
  
  Isn't this easy?  Am I missing something?
  
You  are missing the fact that your english text isn't executable.
Translated to gmp speak, your suggested algorithm is indeed what
has been implemented.

-- 
Torbjörn