This section describes functions for converting GMP integers to standard C types. Functions for converting to GMP integers are described in section Assignment Functions and section Input and Output Functions.
The function mpz_size
can be used to determine the useful range for
n.
mpz_tdiv_q_2exp(..., op, CHAR_BIT*sizeof(unsigned long
int))
can be used to decompose an integer into unsigned longs.
signed long int
return the value of op.
Otherwise return the least significant part of op, with the same sign
as op.
If op is too large to fit in a signed long int
, the returned
result is probably not very useful. To find out if the value will fit, use
the function mpz_fits_slong_p
.
If str is NULL
, space for the result string is allocated using the
default allocation function.
If str is not NULL
, it should point to a block of storage enough large
for the result. To find out the right amount of space to provide for
str, use mpz_sizeinbase (op, base) + 2
. The two
extra bytes are for a possible minus sign, and for the terminating null
character.
A pointer to the result string is returned. This pointer will will either
equal str, or if that is NULL
, will point to the allocated storage.
Go to the first, previous, next, last section, table of contents.