Provides random number generation functionality for integers, floats, and boolean values. More...
#include <stdlib.h>#include <time.h>#include <stdbool.h>Go to the source code of this file.
Functions | |
| void | RandomInit () |
| Initializes the random number generator. | |
| int | RandInt (int min, int max) |
| Generates a random integer between min and max (inclusive). | |
| float | RandFloat (float min, float max) |
| Generates a random float between min and max. | |
| bool | RandBool () |
| Generates a random boolean value. | |
Provides random number generation functionality for integers, floats, and boolean values.
These functions can be used to generate random integers and floats. To use these functions, call RandomInit() once at the start of the program. Then, call RandInt() or RandFloat() to get random numbers.
| bool RandBool | ( | ) |
Generates a random boolean value.
Generates a random boolean value.
Returns either true or false with equal probability (50%).
| float RandFloat | ( | float | min, |
| float | max | ||
| ) |
Generates a random float between min and max.
| min | The minimum value. |
| max | The maximum value. |
Generates a random float between min and max.
Creates a random floating-point value that is >= min and <= max. The distribution is uniform across the range.
| min | The minimum value (inclusive) |
| max | The maximum value (inclusive) |
| int RandInt | ( | int | min, |
| int | max | ||
| ) |
Generates a random integer between min and max (inclusive).
| min | The minimum value. |
| max | The maximum value. |
Generates a random integer between min and max (inclusive).
Creates a random integer value that is >= min and <= max. The distribution is uniform across the range.
| min | The minimum value (inclusive) |
| max | The maximum value (inclusive) |
| void RandomInit | ( | ) |
Initializes the random number generator.
This function should be called once at the start of the program.
Initializes the random number generator.
Seeds the random number generator with a time-based value to ensure different sequences on each program run.