Click or drag to resize
gmp_libmpn_random2 Method
Generate a random number of length r1n and store it at r1p.

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 mpn_random2(
	mp_ptr r1p,
	mp_size_t r1n
)

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
The result integer.
r1n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of r1p.
Remarks

The most significant limb is always non-zero. mpn_random generates uniformly distributed limb data, mpn_random2 generates long strings of zeros and ones in the binary representation.

mpn_random2 is intended for testing the correctness of the mpn routines.

Examples
// Create multi-precision operand.
mp_ptr r1p = new mp_ptr(new uint[2]);

// Generate random number.
gmp_lib.mpn_random2(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1);

// Release unmanaged memory.
gmp_lib.free(r1p);
See Also