From d31163fde6732b9e050afd3923b584ae8dd64b03 Mon Sep 17 00:00:00 2001 From: Anthony Lombardi <30351234+NicerNewerCar@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:49:27 -0400 Subject: [PATCH] BUG: Ensure getRandom() returns values within range (#219) Co-authored-by: Jean-Christophe Fillion-Robin --- libautoscoper/src/PSO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libautoscoper/src/PSO.cpp b/libautoscoper/src/PSO.cpp index 6491687e..9ea0c148 100644 --- a/libautoscoper/src/PSO.cpp +++ b/libautoscoper/src/PSO.cpp @@ -38,7 +38,7 @@ void intializeRandom() float getRandom(float low, float high) { - return low + (high - low + 1.0f)*(float)rand() / (RAND_MAX + 1.0f); + return low + getRandomClamped() * (high - low); } float getRandomClamped()