Skip to content
Snippets Groups Projects
Commit 2b5a9049 authored by Martine Lenders's avatar Martine Lenders
Browse files

Merge pull request #3440 from authmillenon/random/feat/range

random: provide range functionality
parents 1b470665 94f913c2
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,20 @@ void genrand_init_by_array(uint32_t init_key[], int key_length); ...@@ -54,6 +54,20 @@ void genrand_init_by_array(uint32_t init_key[], int key_length);
*/ */
uint32_t genrand_uint32(void); uint32_t genrand_uint32(void);
/**
* @brief generates a random number r with a < r <= b.
*
* @param[in] a minimum for random number
* @param[in] b upper bound for random number
*
* @pre a < b
*
* @return a random number on [a,b)-interval
*/
static inline uint32_t genrand_uint32_range(uint32_t a, uint32_t b)
{
return (genrand_uint32() % (b - a)) + a;
}
#if PRNG_FLOAT #if PRNG_FLOAT
/* These real versions are due to Isaku Wada, 2002/01/09 added */ /* These real versions are due to Isaku Wada, 2002/01/09 added */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment