diff options
Diffstat (limited to '3rdparty/lua/src/lmathlib.c')
-rw-r--r-- | 3rdparty/lua/src/lmathlib.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/3rdparty/lua/src/lmathlib.c b/3rdparty/lua/src/lmathlib.c index 002c508bc46..f528f05d9f6 100644 --- a/3rdparty/lua/src/lmathlib.c +++ b/3rdparty/lua/src/lmathlib.c @@ -240,7 +240,7 @@ static int math_max (lua_State *L) { */ static int math_random (lua_State *L) { lua_Integer low, up; - double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0)); + double r = (double)(1.0 * l_rand()) * (1.0 / ((double)L_RANDMAX + 1.0)); switch (lua_gettop(L)) { /* check number of arguments */ case 0: { /* no arguments */ lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */ @@ -269,7 +269,8 @@ static int math_random (lua_State *L) { static int math_randomseed (lua_State *L) { - l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1)); + lua_Number seed = (lua_Number)luaL_checknumber(L, 1); + l_srand((unsigned int)seed); (void)rand(); /* discard first value to avoid undesirable correlations */ return 0; } |