Setting and clearing multiple bits
Roberto Bagnara
bagnara at cs.unipr.it
Thu Sep 4 10:43:13 CEST 2008
Hi there,
I need to efficiently implement two functions:
//! Sets the bits of \p x up to position \p k (included).
void set_until(mpz_t x, unsigned long k);
//! Clears the bits of \p x from position \p k (included) onward.
void clear_from(mpz_t x, unsigned long k);
For the secone one, I currently have:
inline
clear_from(mpz_t x, unsigned long k) {
mpz_tdiv_r_2exp(x, x, k);
}
Is this the best I can do? And how could I efficiently
compute set_until()?
All the best,
Roberto
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it
More information about the gmp-discuss
mailing list