controllib: fix implicit cast warn with clang 10

This commit is contained in:
Julian Oes 2020-05-19 11:06:54 +02:00 committed by Daniel Agar
parent 4f82f028e7
commit 44be9d5568
2 changed files with 3 additions and 3 deletions

View File

@ -78,8 +78,8 @@ public:
if (phase == 0) {
do {
float U1 = (float)rand() / RAND_MAX;
float U2 = (float)rand() / RAND_MAX;
float U1 = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
float U2 = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
V1 = 2 * U1 - 1;
V2 = 2 * U2 - 1;
S = V1 * V1 + V2 * V2;

View File

@ -75,7 +75,7 @@ public:
virtual ~BlockRandUniform() = default;
float update()
{
static float rand_max = RAND_MAX;
static float rand_max = static_cast<float>(RAND_MAX);
float rand_val = rand();
float bounds = getMax() - getMin();
return getMin() + (rand_val * bounds) / rand_max;