hi,
I think the implementation of (integer) right shift is wrong for
negative values of a in e.g. a >> b.
The implementation of __gmp_binary_rshift::eval( mpz... ) is based on
mpz_tdiv_q_2exp, but should have been based on mpz_fdiv_q_2exp.
Example: -129 >> 8 (.... 1111 1111 0111 1111 >> 8) gives 0, whereas the
correct result is -1.
Another way to put things:
For negative a, a >> b can be calculated as ~( ~a >> b), which here
becomes ~( 128 >> 8) or ~0 which equals -1.
kind regards
niels rose hansen
_______________________________________________
Bug-gmp mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gmp