Bitwise logic gmpxx.h problems
tg at swox.com
Sat Jul 26 12:32:07 CEST 2008
Marc Glisse <marc.glisse at normalesup.org> writes:
The proposed patches for & and &= add an overload of eval() for
__gmp_binary_and for unsigned long and add operators & and &= for all
numeric types (signed/unsigned char/shot/int/long and float/double) that
end up calling the eval() overloaded for unsigned long.
Casting to unsigned long seems ok to me for integer types (don't know what
the meaning is of & with a negative argument) but not for float/double,
where something else should be done. The simplest is probably to overload
eval() for double as well as unsigned long. And then also overload it for
signed long, otherwise there will be ambiguities. This way the bit
operations look the same as addition in gmpxx. That means 12 more
functions compared to the already proposed changes.
Marc and Joppe!
Thanks for the explanations. I think I now understand what needs to
For GMP 4.3, it would be nice to decrease the code repetitions and
avoid many mpz_init/mpz_clear by doig stack allocations.
More information about the gmp-bugs