# Obtaining integer digits using the GNU Multiprecision Arithmetic Library (gmplib)

I'm using the GNU Multiprecision Arithmetic Library (gmplib) for some experiments in computational mathematics. I want to extract, and manipulate, the base-b digits (with 2 <= b <= 10) of unsigned integers (represented in gmplib as type mpz_t) and would prefer to choose the most efficient method I can without having to write a custom function. How should I do it? And if there isn't a good solution to an arbitrary base, is there a good solution for base 10?

I've looked at the functions mpz_out_str() and gmp_snprintf() but neither seems quite suited to the task.

Note: I'm not at all sure what tags to attach to this, and would be happy for a moderator to edit out this note, and alter the tags!