Validate parameters of randi_range()
This commit is contained in:
parent
30e8b53c38
commit
d89478975f
1 changed files with 4 additions and 1 deletions
|
@ -59,7 +59,10 @@ public:
|
||||||
|
|
||||||
_FORCE_INLINE_ int randi_range(int from, int to) {
|
_FORCE_INLINE_ int randi_range(int from, int to) {
|
||||||
unsigned int ret = randbase.rand();
|
unsigned int ret = randbase.rand();
|
||||||
return ret % (to - from + 1) + from;
|
if (to < from)
|
||||||
|
return ret % (from - to + 1) + to;
|
||||||
|
else
|
||||||
|
return ret % (to - from + 1) + from;
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomNumberGenerator();
|
RandomNumberGenerator();
|
||||||
|
|
Loading…
Reference in a new issue