diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-05-02 14:31:54 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-05-02 14:31:54 -0300 |
| commit | 29fe3abda2f59005c94f9ad0f9b287bfcbacb710 (patch) | |
| tree | 6663c438c109ea34d54074de49736f7880c0f467 | |
| parent | 6347004be9bed939416af8a59917eb30d10c1849 (diff) | |
| download | lua-29fe3abda2f59005c94f9ad0f9b287bfcbacb710.tar.gz lua-29fe3abda2f59005c94f9ad0f9b287bfcbacb710.tar.bz2 lua-29fe3abda2f59005c94f9ad0f9b287bfcbacb710.zip | |
new function 'math.isfloat'
| -rw-r--r-- | lmathlib.c | 9 |
1 files changed, 8 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.82 2013/01/29 16:00:40 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.83 2013/03/07 18:21:32 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 | */ |
| @@ -230,6 +230,12 @@ static int math_randomseed (lua_State *L) { | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | 232 | ||
| 233 | static int math_isfloat (lua_State *L) { | ||
| 234 | luaL_checkany(L, 1); | ||
| 235 | lua_pushboolean(L, (lua_type(L, 1) == LUA_TNUMBER && !lua_isinteger(L, 1))); | ||
| 236 | return 1; | ||
| 237 | } | ||
| 238 | |||
| 233 | static const luaL_Reg mathlib[] = { | 239 | static const luaL_Reg mathlib[] = { |
| 234 | {"abs", math_abs}, | 240 | {"abs", math_abs}, |
| 235 | {"acos", math_acos}, | 241 | {"acos", math_acos}, |
| @@ -244,6 +250,7 @@ static const luaL_Reg mathlib[] = { | |||
| 244 | {"floor", math_floor}, | 250 | {"floor", math_floor}, |
| 245 | {"fmod", math_fmod}, | 251 | {"fmod", math_fmod}, |
| 246 | {"frexp", math_frexp}, | 252 | {"frexp", math_frexp}, |
| 253 | {"isfloat", math_isfloat}, | ||
| 247 | {"ldexp", math_ldexp}, | 254 | {"ldexp", math_ldexp}, |
| 248 | #if defined(LUA_COMPAT_LOG10) | 255 | #if defined(LUA_COMPAT_LOG10) |
| 249 | {"log10", math_log10}, | 256 | {"log10", math_log10}, |
