Go backward to I/O of Integers.
Go up to Integer Functions.
Miscellaneous Functions
=======================
- Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE)
Generate a random integer of at most MAX_SIZE limbs. The generated
random number doesn't satisfy any particular requirements of
randomness. Negative random numbers are generated when MAX_SIZE
is negative.
- Function: void mpz_random2 (mpz_t ROP, mp_size_t MAX_SIZE)
Generate a random integer of at most MAX_SIZE limbs, with long
strings of zeros and ones in the binary representation. Useful
for testing functions and algorithms, since this kind of random
numbers have proven to be more likely to trigger corner-case bugs.
Negative random numbers are generated when MAX_SIZE is negative.
- Function: size_t mpz_size (mpz_t OP)
Return the size of OP measured in number of limbs. If OP is zero,
the returned value will be zero.
*This function is obsolete. It will disappear from future MP
releases.*
- Function: size_t mpz_sizeinbase (mpz_t OP, int BASE)
Return the size of OP measured in number of digits in base BASE.
The base may vary from 2 to 36. The returned value will be exact
or 1 too big. If BASE is a power of 2, the returned value will
always be exact.
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
terminating '\0').