|
@@ -58,12 +58,18 @@ public:
|
|
|
_FORCE_INLINE_ real_t randfn(real_t mean = 0.0, real_t deviation = 1.0) { return randbase.randfn(mean, deviation); }
|
|
|
|
|
|
_FORCE_INLINE_ int randi_range(int from, int to) {
|
|
|
- unsigned int ret = randbase.rand();
|
|
|
- if (to < from) {
|
|
|
- return ret % (from - to + 1) + to;
|
|
|
- } else {
|
|
|
- return ret % (to - from + 1) + from;
|
|
|
+ int range;
|
|
|
+ int min;
|
|
|
+ if (to > from) {
|
|
|
+ range = to - from + 1;
|
|
|
+ min = from;
|
|
|
+ } else if (to < from) {
|
|
|
+ range = from - to + 1;
|
|
|
+ min = to;
|
|
|
+ } else { // from == to
|
|
|
+ return from;
|
|
|
}
|
|
|
+ return randbase.rand(range) + min;
|
|
|
}
|
|
|
|
|
|
RandomNumberGenerator() {}
|