diff options
Diffstat (limited to 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 58 |
1 files changed, 29 insertions, 29 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.34 2001/02/02 19:02:40 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.35 2001/02/22 18:59:59 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 | */ |
@@ -176,18 +176,18 @@ static int math_random (lua_State *L) { | |||
176 | } | 176 | } |
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, l_s("interval is empty")); |
180 | lua_pushnumber(L, (int)(r*u)+1); /* integer between 1 and `u' */ | 180 | lua_pushnumber(L, (int)(r*u)+1); /* integer 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, l_s("interval is empty")); |
187 | lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */ | 187 | lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */ |
188 | break; | 188 | break; |
189 | } | 189 | } |
190 | default: lua_error(L, "wrong number of arguments"); | 190 | default: lua_error(L, l_s("wrong number of arguments")); |
191 | } | 191 | } |
192 | return 1; | 192 | return 1; |
193 | } | 193 | } |
@@ -200,29 +200,29 @@ static int math_randomseed (lua_State *L) { | |||
200 | 200 | ||
201 | 201 | ||
202 | static const luaL_reg mathlib[] = { | 202 | static const luaL_reg mathlib[] = { |
203 | {"abs", math_abs}, | 203 | {l_s("abs"), math_abs}, |
204 | {"sin", math_sin}, | 204 | {l_s("sin"), math_sin}, |
205 | {"cos", math_cos}, | 205 | {l_s("cos"), math_cos}, |
206 | {"tan", math_tan}, | 206 | {l_s("tan"), math_tan}, |
207 | {"asin", math_asin}, | 207 | {l_s("asin"), math_asin}, |
208 | {"acos", math_acos}, | 208 | {l_s("acos"), math_acos}, |
209 | {"atan", math_atan}, | 209 | {l_s("atan"), math_atan}, |
210 | {"atan2", math_atan2}, | 210 | {l_s("atan2"), math_atan2}, |
211 | {"ceil", math_ceil}, | 211 | {l_s("ceil"), math_ceil}, |
212 | {"floor", math_floor}, | 212 | {l_s("floor"), math_floor}, |
213 | {"mod", math_mod}, | 213 | {l_s("mod"), math_mod}, |
214 | {"frexp", math_frexp}, | 214 | {l_s("frexp"), math_frexp}, |
215 | {"ldexp", math_ldexp}, | 215 | {l_s("ldexp"), math_ldexp}, |
216 | {"sqrt", math_sqrt}, | 216 | {l_s("sqrt"), math_sqrt}, |
217 | {"min", math_min}, | 217 | {l_s("min"), math_min}, |
218 | {"max", math_max}, | 218 | {l_s("max"), math_max}, |
219 | {"log", math_log}, | 219 | {l_s("log"), math_log}, |
220 | {"log10", math_log10}, | 220 | {l_s("log10"), math_log10}, |
221 | {"exp", math_exp}, | 221 | {l_s("exp"), math_exp}, |
222 | {"deg", math_deg}, | 222 | {l_s("deg"), math_deg}, |
223 | {"rad", math_rad}, | 223 | {l_s("rad"), math_rad}, |
224 | {"random", math_random}, | 224 | {l_s("random"), math_random}, |
225 | {"randomseed", math_randomseed} | 225 | {l_s("randomseed"), math_randomseed} |
226 | }; | 226 | }; |
227 | 227 | ||
228 | /* | 228 | /* |
@@ -231,8 +231,8 @@ static const luaL_reg mathlib[] = { | |||
231 | LUALIB_API void lua_mathlibopen (lua_State *L) { | 231 | LUALIB_API void lua_mathlibopen (lua_State *L) { |
232 | luaL_openl(L, mathlib); | 232 | luaL_openl(L, mathlib); |
233 | lua_pushcfunction(L, math_pow); | 233 | lua_pushcfunction(L, math_pow); |
234 | lua_settagmethod(L, LUA_TNUMBER, "pow"); | 234 | lua_settagmethod(L, LUA_TNUMBER, l_s("pow")); |
235 | lua_pushnumber(L, PI); | 235 | lua_pushnumber(L, PI); |
236 | lua_setglobal(L, "PI"); | 236 | lua_setglobal(L, l_s("PI")); |
237 | } | 237 | } |
238 | 238 | ||