Next: Integer Import and Export, Previous: I/O of Integers, Up: Integer Functions [Index]
The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the Random Number Functions for more information on how to use and not to use random number functions.
Generate a uniformly distributed random integer in the range 0 to 2n-1, inclusive.
The variable state must be initialized by calling one of the
gmp_randinit
functions (Random State Initialization) before
invoking this function.
Generate a uniform random integer in the range 0 to n-1, inclusive.
The variable state must be initialized by calling one of the
gmp_randinit
functions (Random State Initialization)
before invoking this function.
Generate a random integer 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. The random number will be in the range 2n-1 to 2n-1, inclusive.
The variable state must be initialized by calling one of the
gmp_randinit
functions (Random State Initialization)
before invoking this function.
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.
This function is obsolete. Use mpz_urandomb
or
mpz_urandomm
instead.
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.
This function is obsolete. Use mpz_rrandomb
instead.
Next: Integer Import and Export, Previous: I/O of Integers, Up: Integer Functions [Index]