A newbie question
Bird, John
John.Bird at ca.com
Tue Aug 18 10:51:47 CEST 2009
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?
Regards,
John
-----Original Message-----
From: gmp-discuss-bounces at gmplib.org
[mailto:gmp-discuss-bounces at gmplib.org] On Behalf Of David Gillies
Sent: Monday, August 17, 2009 11:59 PM
To: gmp-discuss at gmplib.org
Subject: Re: A newbie question
Digit extraction in this case is tantamount to base conversion. For a
non-power of two base this is hard.
On Sun, Aug 16, 2009 at 8:09 PM, Bird, John<John.Bird at ca.com> wrote:
> Hi Guys
>
>
>
> I'm looking through the manual for a function that pulls out the Xth
> digit of an int.
>
> So something like this:
>
>
>
> unsigned long uslong;
>
>
>
> mpz_set_str(n, "111111111111111911111", 10);
>
> uslong = mpz_get_index_ui(n, 5);
>
>
>
> uslong would now equal 9
>
>
>
> The closest thing in the manual I can find is mpz_getlimbn. Is this
the
> function I am looking for? If so, can anyone suggest an efficient way
of
> calculating an "index" from that?
>
>
>
> Many thanks,
>
> John
>
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>
--
David Gillies
San Jose
Costa Rica
_______________________________________________
gmp-discuss mailing list
gmp-discuss at gmplib.org
https://gmplib.org/mailman/listinfo/gmp-discuss
More information about the gmp-discuss
mailing list