Skip to content

Commit

Permalink
BUG: Ensure getRandom() returns values within range (#219)
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
  • Loading branch information
NicerNewerCar and jcfr authored Oct 24, 2023
1 parent 7accc20 commit d31163f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libautoscoper/src/PSO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d31163f

Please sign in to comment.