blob: 821ddc854b4d5ec74a9f03d1bd3bec4820017552 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <cstdlib>
#include "Random.h"
float Random::f(float upper, float lower) {
float range = upper - lower;
float x = ((float) rand() / (float) (RAND_MAX)) * range;
return x + lower;
}
double Random::d(double upper, double lower) {
double range = upper - lower;
double x = ((double) rand() / (double) (RAND_MAX)) * range;
return x + lower;
}
int Random::i(int upper, int lower) {
int range = upper - lower;
int x = rand() % range;
return x + lower;
}
unsigned Random::u(unsigned upper, unsigned lower) {
unsigned range = upper - lower;
unsigned x = rand() % range;
return x + lower;
}
bool Random::b() {
return rand() % 2;
}
|