gmp_lib.mpf_random2 Method

GMP Native Interface for .NET

gmp_libmpf_random2 Method
Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation.

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_random2(
	mpf_t rop,
	mp_size_t max_size,
	mp_exp_t exp
)
Public Shared Sub mpf_random2 ( 
	rop As mpf_t,
	max_size As mp_size_t,
	exp As mp_exp_t
)
public:
static void mpf_random2(
	mpf_t^ rop, 
	mp_size_t max_size, 
	mp_exp_t exp
)
static member mpf_random2 : 
        rop : mpf_t * 
        max_size : mp_size_t * 
        exp : mp_exp_t -> unit 

Parameters

rop
Type: Math.Gmp.Nativempf_t
The result float.
max_size
Type: Math.Gmp.Nativemp_size_t
The maximum number of limbs.
exp
Type: Math.Gmp.Nativemp_exp_t
The range of the random exponent.
Remarks

The exponent of the number is in the interval -exp to exp (in limbs). This function is useful for testing functions and algorithms, since these kind of random numbers have proven to be more likely to trigger corner-case bugs. Negative random numbers are generated when max_size is negative.

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

// Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5].
gmp_lib.mpf_random2(rop, 10, 5);

// Free all memory occupied by rop.
gmp_lib.mpf_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpf_t()
gmp_lib.mpf_init(rop)

' Generate a random floating-point number with at most 10 limbs and its exponent in [-5 5].
gmp_lib.mpf_random2(rop, 10, 5)

' Free all memory occupied by rop.
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.

See Also