summaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 6fc9f78f..ee53f52e 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,6 +1,6 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.21 1999/11/22 17:39:51 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.22 1999/12/14 18:31:20 roberto Exp roberto $
3** Lua standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
@@ -147,7 +147,7 @@ static void math_random (lua_State *L) {
147 some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */ 147 some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */
148 double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX; 148 double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX;
149 if (lua_getparam(L, 1) == LUA_NOOBJECT) /* no arguments? */ 149 if (lua_getparam(L, 1) == LUA_NOOBJECT) /* no arguments? */
150 lua_pushnumber(L, r); /* real between 0 & 1 */ 150 lua_pushnumber(L, r); /* real between 0 and 1 */
151 else { 151 else {
152 int l, u; /* lower & upper limits */ 152 int l, u; /* lower & upper limits */
153 if (lua_getparam(L, 2) == LUA_NOOBJECT) { /* only one argument? */ 153 if (lua_getparam(L, 2) == LUA_NOOBJECT) { /* only one argument? */
@@ -159,7 +159,7 @@ static void math_random (lua_State *L) {
159 u = luaL_check_int(L, 2); 159 u = luaL_check_int(L, 2);
160 } 160 }
161 luaL_arg_check(L, l<=u, 1, "interval is empty"); 161 luaL_arg_check(L, l<=u, 1, "interval is empty");
162 lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between l & u */ 162 lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */
163 } 163 }
164} 164}
165 165