A newbie question

Christ Schlacta aarcane at gmail.com
Tue Aug 18 19:36:31 CEST 2009


you could also try convert it to a string and use string character 
extraction in combination with atoi to retrieve the value you want.

David Gillies wrote:
> 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().
> 


More information about the gmp-discuss mailing list