GMP Native Interface for .NET
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)

public static void mpf_urandomb( mpf_t rop, gmp_randstate_t state, mp_bitcnt_t nbits )
Public Shared Sub mpf_urandomb ( rop As mpf_t, state As gmp_randstate_t, nbits As mp_bitcnt_t )
public: static void mpf_urandomb( mpf_t^ rop, gmp_randstate_t^ state, mp_bitcnt_t nbits )
static member mpf_urandomb : rop : mpf_t * state : gmp_randstate_t * nbits : mp_bitcnt_t -> unit
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.

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

// 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);
' Create, initialize, and seed a new random number generator. Dim state As New gmp_randstate_t() gmp_lib.gmp_randinit_mt(state) gmp_lib.gmp_randseed_ui(state, 100000UI) ' Create, initialize, and set the value of rop to 0. Dim rop As 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)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
