gmp_lib.gmp_urandomb_ui Method

GMP Native Interface for .NET

gmp_libgmp_urandomb_ui Method
Generate a uniformly distributed random number of n bits, i.e. in the range 0 to 2^n - 1 inclusive.

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 uint gmp_urandomb_ui(
	gmp_randstate_t state,
	uint n
)
Public Shared Function gmp_urandomb_ui ( 
	state As gmp_randstate_t,
	n As UInteger
) As UInteger
public:
static unsigned int gmp_urandomb_ui(
	gmp_randstate_t^ state, 
	unsigned int n
)
static member gmp_urandomb_ui : 
        state : gmp_randstate_t * 
        n : uint32 -> uint32 

Parameters

state
Type: Math.Gmp.Nativegmp_randstate_t
The state of the random number generator to use.
n
Type: SystemUInt32
The numbe rof bits.

Return Value

Type: UInt32
The generated random number.
Remarks

n must be less than or equal to the number of bits in an unsigned long.

In .NET, n must be less than or equal to the number of bits in an unsigned 32-bit integer.

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);

// Generate a random integer in the range [0, 2^8-1].
uint rand = gmp_lib.gmp_urandomb_ui(state, 8);

// Free all memory occupied by state.
gmp_lib.gmp_randclear(state);
' 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)

' Generate a random integer in the range [0, 2^8-1].
Dim rand As UInteger = gmp_lib.gmp_urandomb_ui(state, 8)

' Free all memory occupied by state.
gmp_lib.gmp_randclear(state)

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