Random Numbers

Random Numbers — Various functions returning random numbers

Functions

Description

The following functions provide an easy way to get random floating point numbers. All functions using the internal rand() function to generate random numbers.

Functions

clampf ()

gfloat
clampf (gfloat num,
        gfloat min,
        gfloat max);

Parameters

num

A number

 

min

A number to use as minimum

 

max

A number to use as maximum

 

Returns

min if num < min , max if num > max and num in all other cases


rand1f ()

gfloat
rand1f (gfloat max);

Parameters

max

A number to use as maximum

 

Returns

A random floating point number between 0 and max


rand2f ()

gfloat
rand2f (gfloat min,
        gfloat max);

Parameters

min

A number to use as minimum

 

max

A number to use as maximum

 

Returns

A random floating point number between min and max


randf ()

gfloat
randf (void);

Returns

A random floating point number between 0 and 1

Types and Values