diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-28 14:35:47 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-28 14:35:47 -0300 |
commit | 925d1b59f931ad3cf23e67f39f6771b9a9e06f5f (patch) | |
tree | fe9154d25e0cb6bb0c0cc682abc96b35c4ff7d1d /lmathlib.c | |
parent | 03bbe1baf190ec768690805b967571b78c8dd34b (diff) | |
download | lua-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.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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 | |||
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 | |||
167 | static int math_log (lua_State *L) { | 175 | static 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}, |