Click or drag to resize
gmp_libgmp_urandomm_ui Method
Generate a uniformly distributed random number in the range 0 to n - 1, inclusive.

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 uint gmp_urandomm_ui(
	gmp_randstate_t state,
	uint n
)

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state of the random number generator to use.
n
Type: SystemUInt32
The upper bound of the range.

Return Value

Type: UInt32
The generated random number.
Examples
// Create, initialize, and seed a new random number generator.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
gmp_lib.gmp_randseed_ui(state, 1000U);

// Generate a random integer in the range [0, 8-1].
uint rand = gmp_lib.gmp_urandomm_ui(state, 8);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
See Also