Click or drag to resize
gmp_libmpf_urandomb Method
Generate a uniformly distributed random float in rop, such that 0 ≤ rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.

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 mpf_urandomb(
	mpf_t rop,
	gmp_randstate_t state,
	mp_bitcnt_t nbits
)

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
state
Type: Math.Gmp.Nativegmp_randstate_t
The random number generator state.
nbits
Type: Math.Gmp.Nativemp_bitcnt_t
Number of significant bits.
Remarks

The variable state must be initialized by calling one of the gmp_randinit functions (GNU MP - Random State Initialization) before invoking this function.

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, 100000U);

// Create, initialize, and set the value of rop to 0.
mpf_t rop = new mpf_t();
gmp_lib.mpf_init(rop);

// Generate a random integer in the range [0, 1) with 50 bits precision.
gmp_lib.mpf_urandomb(rop, state, 50);

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