COMMON: Add a signed variant of getRandomNumberRng.
Useful for generating negative numbers
This commit is contained in:
parent
bf46d8e677
commit
18626c2e96
2 changed files with 12 additions and 0 deletions
|
@ -59,4 +59,8 @@ uint RandomSource::getRandomNumberRng(uint min, uint max) {
|
|||
return getRandomNumber(max - min) + min;
|
||||
}
|
||||
|
||||
int RandomSource::getRandomNumberRngSigned(int min, int max) {
|
||||
return getRandomNumber(max - min) + min;
|
||||
}
|
||||
|
||||
} // End of namespace Common
|
||||
|
|
|
@ -82,6 +82,14 @@ public:
|
|||
* @return a random number in the interval [min, max]
|
||||
*/
|
||||
uint getRandomNumberRng(uint min, uint max);
|
||||
|
||||
/**
|
||||
* Generates a random signed integer in the interval [min, max].
|
||||
* @param min the lower bound
|
||||
* @param max the upper bound
|
||||
* @return a random number in the interval [min, max]
|
||||
*/
|
||||
int getRandomNumberRngSigned(int min, int max);
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue