diff options
Diffstat (limited to 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.55 2003/03/11 12:24:34 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.56 2003/03/11 12:30:37 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 | */ |
@@ -128,7 +128,7 @@ static int math_rad (lua_State *L) { | |||
128 | static int math_frexp (lua_State *L) { | 128 | static int math_frexp (lua_State *L) { |
129 | int e; | 129 | int e; |
130 | lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); | 130 | lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); |
131 | lua_pushnumber(L, e); | 131 | lua_pushinteger(L, e); |
132 | return 2; | 132 | return 2; |
133 | } | 133 | } |
134 | 134 | ||
@@ -179,14 +179,14 @@ static int math_random (lua_State *L) { | |||
179 | case 1: { /* only upper limit */ | 179 | case 1: { /* only upper limit */ |
180 | int u = luaL_checkint(L, 1); | 180 | int u = luaL_checkint(L, 1); |
181 | luaL_argcheck(L, 1<=u, 1, "interval is empty"); | 181 | luaL_argcheck(L, 1<=u, 1, "interval is empty"); |
182 | lua_pushnumber(L, (int)floor(r*u)+1); /* int between 1 and `u' */ | 182 | lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ |
183 | break; | 183 | break; |
184 | } | 184 | } |
185 | case 2: { /* lower and upper limits */ | 185 | case 2: { /* lower and upper limits */ |
186 | int l = luaL_checkint(L, 1); | 186 | int l = luaL_checkint(L, 1); |
187 | int u = luaL_checkint(L, 2); | 187 | int u = luaL_checkint(L, 2); |
188 | luaL_argcheck(L, l<=u, 2, "interval is empty"); | 188 | luaL_argcheck(L, l<=u, 2, "interval is empty"); |
189 | lua_pushnumber(L, (int)floor(r*(u-l+1))+l); /* int between `l' and `u' */ | 189 | lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | default: return luaL_error(L, "wrong number of arguments"); | 192 | default: return luaL_error(L, "wrong number of arguments"); |