Go to the first, previous, next, last section, table of contents.


Conversion Functions

This section describes functions for converting arbitrary precision integers to standard C types. Functions for converting to arbitrary precision integers are described in section Assignment Functions and section Input and Output Functions.

Function: unsigned long int mpz_get_ui (mpz_t op)
Return the least significant part from op. This function combined with
mpz_tdiv_q_2exp(..., op, CHAR_BIT*sizeof(unsigned long int)) can be used to extract the limbs of an integer efficiently.

Function: signed long int mpz_get_si (mpz_t op)
If op fits into a 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.

Function: char * mpz_get_str (char *str, int base, mpz_t op)
Convert op to a string of digits in base base. The base may vary from 2 to 36.

If str is NULL, space for the result string is allocated using the default allocation function, and a pointer to the string is returned.

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.


Go to the first, previous, next, last section, table of contents.