A newbie question

David Gillies daggillies at gmail.com
Tue Aug 18 18:55:35 CEST 2009

On Tue, Aug 18, 2009 at 2:51 AM, Bird, John<John.Bird at ca.com> wrote:
> Thank you all for your responses.
> I was using the (n / 10^x) % 10 method already but was hoping that I
> could exploit the fact that gmp stores numbers in an array to somehow
> reduce the amount of work necessary to derive.
> David - I don't have to be using base 10 here. I don't suppose the gmp
> libraries support efficient digit extraction for any power of 2 base?
Power of two base digit extraction is still (n/base^x)%base, but that
reduces to right shift and mask, which are much faster primitives.
Look at mpz_fdiv_q_2exp() and mpx_ior().

David Gillies
San Jose
Costa Ricaq_2exp

More information about the gmp-discuss mailing list