diff options
Diffstat (limited to '3rdparty/lua/src')
-rw-r--r-- | 3rdparty/lua/src/lmathlib.c | 5 | ||||
-rw-r--r-- | 3rdparty/lua/src/loslib.c | 2 |
2 files changed, 4 insertions, 3 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; } diff --git a/3rdparty/lua/src/loslib.c b/3rdparty/lua/src/loslib.c index 20359b24747..d78ff757df9 100644 --- a/3rdparty/lua/src/loslib.c +++ b/3rdparty/lua/src/loslib.c @@ -152,7 +152,7 @@ static int os_getenv (lua_State *L) { static int os_clock (lua_State *L) { - lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + lua_pushnumber(L, ((lua_Number)(int)clock())/(lua_Number)CLOCKS_PER_SEC); return 1; } |