aboutsummaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-28 14:35:47 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-28 14:35:47 -0300
commit925d1b59f931ad3cf23e67f39f6771b9a9e06f5f (patch)
treefe9154d25e0cb6bb0c0cc682abc96b35c4ff7d1d /lmathlib.c
parent03bbe1baf190ec768690805b967571b78c8dd34b (diff)
downloadlua-925d1b59f931ad3cf23e67f39f6771b9a9e06f5f.tar.gz
lua-925d1b59f931ad3cf23e67f39f6771b9a9e06f5f.tar.bz2
lua-925d1b59f931ad3cf23e67f39f6771b9a9e06f5f.zip
new function 'math.ult' (unsigned less than)
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 79232e4d..43f10d7e 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.106 2014/07/16 13:47:13 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.107 2014/07/17 12:30:53 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*/
@@ -164,6 +164,14 @@ static int math_sqrt (lua_State *L) {
164 return 1; 164 return 1;
165} 165}
166 166
167
168static int math_ult (lua_State *L) {
169 lua_Integer a = luaL_checkinteger(L, 1);
170 lua_Integer b = luaL_checkinteger(L, 2);
171 lua_pushboolean(L, (lua_Unsigned)a < (lua_Unsigned)b);
172 return 1;
173}
174
167static int math_log (lua_State *L) { 175static int math_log (lua_State *L) {
168 lua_Number x = luaL_checknumber(L, 1); 176 lua_Number x = luaL_checknumber(L, 1);
169 lua_Number res; 177 lua_Number res;
@@ -343,6 +351,7 @@ static const luaL_Reg mathlib[] = {
343 {"tointeger", math_toint}, 351 {"tointeger", math_toint},
344 {"floor", math_floor}, 352 {"floor", math_floor},
345 {"fmod", math_fmod}, 353 {"fmod", math_fmod},
354 {"ult", math_ult},
346 {"log", math_log}, 355 {"log", math_log},
347 {"max", math_max}, 356 {"max", math_max},
348 {"min", math_min}, 357 {"min", math_min},