Node:Miscellaneous Integer Functions, Previous:Integer Import and Export, Up:Integer Functions



Miscellaneous Functions

int mpz_fits_ulong_p (mpz_t op) Function
int mpz_fits_slong_p (mpz_t op) Function
int mpz_fits_uint_p (mpz_t op) Function
int mpz_fits_sint_p (mpz_t op) Function
int mpz_fits_ushort_p (mpz_t op) Function
int mpz_fits_sshort_p (mpz_t op) Function
Return non-zero iff the value of op fits in an unsigned long int, signed long int, unsigned int, signed int, unsigned short int, or signed short int, respectively. Otherwise, return zero.

int mpz_odd_p (mpz_t op) Macro
int mpz_even_p (mpz_t op) Macro
Determine whether op is odd or even, respectively. Return non-zero if yes, zero if no. These macros evaluate their argument more than once.

size_t mpz_size (mpz_t op) Function
Return the size of op measured in number of limbs. If op is zero, the returned value will be zero.

size_t mpz_sizeinbase (mpz_t op, int base) Function
Return the size of op measured in number of digits in base base. The base may vary from 2 to 36. The sign of op is ignored, just the absolute value is used. The result will be exact or 1 too big. If base is a power of 2, the result will always be exact. If op is zero the return value is always 1.

This function is useful in order to allocate the right amount of space before converting op to a string. The right amount of allocation is normally two more than the value returned by mpz_sizeinbase (one extra for a minus sign and one for the null-terminator).