Click or drag to resize
gmp_libgmp_randseed_ui Method
Set an initial seed value into state.

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 gmp_randseed_ui(
	gmp_randstate_t state,
	uint seed
)

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state to seed.
seed
Type: SystemUInt32
The seed.
Remarks

The size of a seed determines how many different sequences of random numbers that it’s possible to generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed used, and this affects the randomness of separate number sequences. The method for choosing a seed is critical if the generated numbers are to be used for important applications, such as generating cryptographic keys.

Traditionally the system time has been used to seed, but care needs to be taken with this. If an application seeds often and the resolution of the system clock is low, then the same sequence of numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is required then it should definitely not be the only source for the seed value. On some systems there’s a special device /dev/random which provides random data better suited for use as a seed.

Examples
// Create new random number generator state, and initialize state with the Mersenne Twister algorithm.
gmp_randstate_t state = new gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);

// Seed random number generator.
gmp_lib.gmp_randseed_ui(state, 100000U);

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