aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lmathlib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 81238131..435eeda5 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.47 2002/06/18 15:16:18 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.48 2002/06/24 13:54:13 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*/
@@ -177,14 +177,14 @@ static int math_random (lua_State *L) {
177 case 1: { /* only upper limit */ 177 case 1: { /* only upper limit */
178 int u = luaL_check_int(L, 1); 178 int u = luaL_check_int(L, 1);
179 luaL_arg_check(L, 1<=u, 1, "interval is empty"); 179 luaL_arg_check(L, 1<=u, 1, "interval is empty");
180 lua_pushnumber(L, (int)(r*u)+1); /* integer between 1 and `u' */ 180 lua_pushnumber(L, (int)floor(r*u)+1); /* int between 1 and `u' */
181 break; 181 break;
182 } 182 }
183 case 2: { /* lower and upper limits */ 183 case 2: { /* lower and upper limits */
184 int l = luaL_check_int(L, 1); 184 int l = luaL_check_int(L, 1);
185 int u = luaL_check_int(L, 2); 185 int u = luaL_check_int(L, 2);
186 luaL_arg_check(L, l<=u, 2, "interval is empty"); 186 luaL_arg_check(L, l<=u, 2, "interval is empty");
187 lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */ 187 lua_pushnumber(L, (int)floor(r*(u-l+1))+l); /* int between `l' and `u' */
188 break; 188 break;
189 } 189 }
190 default: return luaL_error(L, "wrong number of arguments"); 190 default: return luaL_error(L, "wrong number of arguments");