From 22715652592b326feae3010a8bc80d6f8fadba50 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 19 Nov 2018 21:20:32 +0800 Subject: =?UTF-8?q?*=E7=B2=92=E5=AD=90=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/math/je_random.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/libjin/math/je_random.cpp') diff --git a/src/libjin/math/je_random.cpp b/src/libjin/math/je_random.cpp index 216fd79..b9313d2 100644 --- a/src/libjin/math/je_random.cpp +++ b/src/libjin/math/je_random.cpp @@ -1,4 +1,5 @@ #include +#include "je_math.h" #include "je_random.h" namespace JinEngine @@ -43,9 +44,10 @@ namespace JinEngine float RandomGenerator::randf(float min, float max, int ac) { + float floor = 0, ceil = max + reverse(min); uint32 a = pow(10.f, ac); - uint32 n = rand(min*a, max*a); - return (float)n / a; + uint32 n = rand(floor*a, ceil*a); + return (float)n / a + min; } } -- cgit v1.1-26-g67d0