diff options
Diffstat (limited to 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.31 2000/10/27 16:15:53 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.32 2000/10/31 13:10:24 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 | */ |
@@ -139,10 +139,10 @@ static int math_ldexp (lua_State *L) { | |||
139 | 139 | ||
140 | static int math_min (lua_State *L) { | 140 | static int math_min (lua_State *L) { |
141 | int n = lua_gettop(L); /* number of arguments */ | 141 | int n = lua_gettop(L); /* number of arguments */ |
142 | double dmin = luaL_check_number(L, 1); | 142 | lua_Number dmin = luaL_check_number(L, 1); |
143 | int i; | 143 | int i; |
144 | for (i=2; i<=n; i++) { | 144 | for (i=2; i<=n; i++) { |
145 | double d = luaL_check_number(L, i); | 145 | lua_Number d = luaL_check_number(L, i); |
146 | if (d < dmin) | 146 | if (d < dmin) |
147 | dmin = d; | 147 | dmin = d; |
148 | } | 148 | } |
@@ -153,10 +153,10 @@ static int math_min (lua_State *L) { | |||
153 | 153 | ||
154 | static int math_max (lua_State *L) { | 154 | static int math_max (lua_State *L) { |
155 | int n = lua_gettop(L); /* number of arguments */ | 155 | int n = lua_gettop(L); /* number of arguments */ |
156 | double dmax = luaL_check_number(L, 1); | 156 | lua_Number dmax = luaL_check_number(L, 1); |
157 | int i; | 157 | int i; |
158 | for (i=2; i<=n; i++) { | 158 | for (i=2; i<=n; i++) { |
159 | double d = luaL_check_number(L, i); | 159 | lua_Number d = luaL_check_number(L, i); |
160 | if (d > dmax) | 160 | if (d > dmax) |
161 | dmax = d; | 161 | dmax = d; |
162 | } | 162 | } |
@@ -168,7 +168,7 @@ static int math_max (lua_State *L) { | |||
168 | static int math_random (lua_State *L) { | 168 | static int math_random (lua_State *L) { |
169 | /* the '%' avoids the (rare) case of r==1, and is needed also because on | 169 | /* the '%' avoids the (rare) case of r==1, and is needed also because on |
170 | some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */ | 170 | some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */ |
171 | double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX; | 171 | lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; |
172 | switch (lua_gettop(L)) { /* check number of arguments */ | 172 | switch (lua_gettop(L)) { /* check number of arguments */ |
173 | case 0: { /* no arguments */ | 173 | case 0: { /* no arguments */ |
174 | lua_pushnumber(L, r); /* Number between 0 and 1 */ | 174 | lua_pushnumber(L, r); /* Number between 0 and 1 */ |