diff options
Diffstat (limited to '')
| -rw-r--r-- | lmathlib.c | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.111 2014/10/24 11:42:06 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.112 2014/11/02 19:19:04 roberto Exp roberto $ |
| 3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -258,8 +258,8 @@ static int math_random (lua_State *L) { | |||
| 258 | } | 258 | } |
| 259 | /* random integer in the interval [low, up] */ | 259 | /* random integer in the interval [low, up] */ |
| 260 | luaL_argcheck(L, low <= up, 1, "interval is empty"); | 260 | luaL_argcheck(L, low <= up, 1, "interval is empty"); |
| 261 | luaL_argcheck(L, (lua_Unsigned)up - low <= (lua_Unsigned)LUA_MAXINTEGER, | 261 | luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, |
| 262 | 1, "interval too large"); | 262 | "interval too large"); |
| 263 | r *= (double)(up - low) + 1.0; | 263 | r *= (double)(up - low) + 1.0; |
| 264 | lua_pushinteger(L, (lua_Integer)r + low); | 264 | lua_pushinteger(L, (lua_Integer)r + low); |
| 265 | return 1; | 265 | return 1; |
