bug / side effects?/ for fdiv?

Richard Fateman fateman@cs.berkeley.edu
Tue, 09 Sep 2003 00:03:35 -0700


I am using gmp 4.1  with common lisp bindings I set up for Allegro Common
Lisp, using foreign function interface.
  .... i and q are gmp numbers...
      (setf r (create_mpz_zero))
      (mpz_fdiv_r_2exp r i logv)    ;set r to remainder i by 2^logv
      (mpz_fdiv_q_2exp q i logv)    ;set q to quotient   i by 2^logv

This works as expected.   the call to mpz_fdiv_q is essentially a right 
shift
by logv bits.

However, if the div_r  and div_q  are reversed, then the remainder is
off by 1. This is repeatable, but doesn't happen on all inputs.


I know that this report is kind of sketchy, and I'm not supplying
you with the full context,  (all is possible, but Allegro is not
open source etc etc etc).

I suspect this could be reproduced in any other language binding
though.


i is 4611682719894601729, logv is 20.

Regards,
 RJF