Skip to content

Commit 925d1b5

Browse files
committed
new function 'math.ult' (unsigned less than)
1 parent 03bbe1b commit 925d1b5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lmathlib.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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 $
33
** Standard mathematical library
44
** See Copyright Notice in lua.h
55
*/
@@ -164,6 +164,14 @@ static int math_sqrt (lua_State *L) {
164164
return 1;
165165
}
166166

167+
168+
static 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+
167175
static int math_log (lua_State *L) {
168176
lua_Number x = luaL_checknumber(L, 1);
169177
lua_Number res;
@@ -343,6 +351,7 @@ static const luaL_Reg mathlib[] = {
343351
{"tointeger", math_toint},
344352
{"floor", math_floor},
345353
{"fmod", math_fmod},
354+
{"ult", math_ult},
346355
{"log", math_log},
347356
{"max", math_max},
348357
{"min", math_min},

0 commit comments

Comments
 (0)