Click or drag to resize
gmp_libmpz_random Method
Generate a random integer of at most max_size limbs.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static void mpz_random(
	mpz_t rop,
	mp_size_t max_size
)

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
max_size
Type: Math.Gmp.Nativemp_size_t
The maximum number of limbs.
Remarks

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.

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 GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Generate a random integer.
gmp_lib.mpz_random(rop, 500);

// Free all memory occupied by state and rop.
gmp_lib.mpz_clear(rop);
See Also