summaryrefslogtreecommitdiff
path: root/src/lmathlib.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2014-03-21 12:00:00 +0000
committerrepogen <>2014-03-21 12:00:00 +0000
commit05a6ab2dd30e7707c7d5424b905eb93a1dd5c5b2 (patch)
treef24db6e4692bebf7031418ff9c3b51b345016023 /src/lmathlib.c
parent87cc247b6b22184fba47184c218a642ea7a49e96 (diff)
downloadlua-github-5.3.0-work2.tar.gz
Lua 5.3.0-work25.3.0-work2
Diffstat (limited to 'src/lmathlib.c')
-rw-r--r--src/lmathlib.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lmathlib.c b/src/lmathlib.c
index f26b05ca..a40a6fb6 100644
--- a/src/lmathlib.c
+++ b/src/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.90 2013/07/03 17:23:19 roberto Exp $
+** $Id: lmathlib.c,v 1.92 2013/07/22 16:05:53 roberto Exp $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -251,9 +251,16 @@ static int math_randomseed (lua_State *L) {
}
-static int math_isfloat (lua_State *L) {
+static int math_type (lua_State *L) {
luaL_checkany(L, 1);
- lua_pushboolean(L, (lua_type(L, 1) == LUA_TNUMBER && !lua_isinteger(L, 1)));
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ if (lua_isinteger(L, 1))
+ lua_pushliteral(L, "integer");
+ else
+ lua_pushliteral(L, "float");
+ }
+ else
+ lua_pushnil(L);
return 1;
}
@@ -273,7 +280,6 @@ static const luaL_Reg mathlib[] = {
{"ifloor", math_ifloor},
{"fmod", math_fmod},
{"frexp", math_frexp},
- {"isfloat", math_isfloat},
{"ldexp", math_ldexp},
#if defined(LUA_COMPAT_LOG10)
{"log10", math_log10},
@@ -291,6 +297,7 @@ static const luaL_Reg mathlib[] = {
{"sqrt", math_sqrt},
{"tanh", math_tanh},
{"tan", math_tan},
+ {"type", math_type},
{NULL, NULL}
};