1#include <stdlib.h>
2#include "random.hpp"
3
4static
5void
6init_srand(void)
7{
8 static bool inited(false);
9 if (!inited)
10 {
11 inited = true;
12 srand(0);
13 }
14}
15
16
17float
18random_value(float pmin, float pmax)
19{
20 int v;
21 float r;
22
23 init_srand();
24 v = rand();
25 r = static_cast<float>(v) / static_cast<float>(RAND_MAX);
26 return pmin + r * (pmax - pmin);
27}
28