Problem with GMP mpz bit functions

Niels Möller nisse at lysator.liu.se
Wed Nov 12 15:44:11 CET 2003


Erik Beese <erikbeese at cogeco.ca> writes:

> I've been trying to use the GMP library to express strings as very
> large numbers using bit mapping. converting from an arbitrary string
> works well but I've been having no luck with the reverse, recovering
> the string from a mpz_t using bit-testing.

You probably want to look at the mpz_import and mpz_export functions.

>     (mychar == (CBIT7 ^ mychar)) ? : mpz_setbit (mympz, bitnum);

This seems very confused. Unless CBIT7 is some really hairy macro, the
above test is equivalent to (CBIT7 == 0), which is independent of
mychar, and probably always false.

/Niels


More information about the gmp-discuss mailing list