diff --git a/source/shared_lib/sources/util/randomgen.cpp b/source/shared_lib/sources/util/randomgen.cpp index 4604be6c..ad44c9c8 100644 --- a/source/shared_lib/sources/util/randomgen.cpp +++ b/source/shared_lib/sources/util/randomgen.cpp @@ -15,9 +15,12 @@ #include "util.h" #include #include "platform_util.h" +#include "math_util.h" #include "leak_dumper.h" using namespace std; +using namespace Shared::Graphics; + namespace Shared { namespace Util { // ===================================================== @@ -71,7 +74,7 @@ int RandomGen::randRange(int min, int max){ // int res = streflop::Random(min, max); // streflop //#else int diff= max-min; - int res= min + static_cast(static_cast(diff+1)*RandomGen::rand() / m); + int res= min + static_cast(truncateDecimal(static_cast(diff+1))*RandomGen::rand() / m); //#endif assert(res>=min && res<=max); if(res < min || res > max) { @@ -98,6 +101,7 @@ float RandomGen::randRange(float min, float max){ //#else float rand01= static_cast(RandomGen::rand())/(m-1); float res= min+(max-min)*rand01; + res = truncateDecimal(res); //#endif assert(res>=min && res<=max);