History

Lua 5.3.0-work2

Lua Team committed 12 years ago

Commit ad386d91 parent b83a40a60 files · +3280 −2672Browse files

Showing the changes to src/lmathlib.c (1 of 60 files). Show all

Unified · Split

src/lmathlib.c+11−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lmathlib.c,v 1.90 2013/07/03 17:23:19 roberto Exp $
2+** $Id: lmathlib.c,v 1.92 2013/07/22 16:05:53 roberto Exp $
33 ** Standard mathematical library
44 ** See Copyright Notice in lua.h
55 */
@@ -251,9 +251,16 @@ static int math_randomseed (lua_State *L) { · 245 unmodified lines
251251 }
252252
253253
254−static int math_isfloat (lua_State *L) {
254+static int math_type (lua_State *L) {
255255 luaL_checkany(L, 1);
256− lua_pushboolean(L, (lua_type(L, 1) == LUA_TNUMBER && !lua_isinteger(L, 1)));
256+ if (lua_type(L, 1) == LUA_TNUMBER) {
257+ if (lua_isinteger(L, 1))
258+ lua_pushliteral(L, "integer");
259+ else
260+ lua_pushliteral(L, "float");
261+ }
262+ else
263+ lua_pushnil(L);
257264 return 1;
258265 }
259266
@@ -273,7 +280,6 @@ static const luaL_Reg mathlib[] = { · 13 unmodified lines
273280 {"ifloor", math_ifloor},
274281 {"fmod", math_fmod},
275282 {"frexp", math_frexp},
276− {"isfloat", math_isfloat},
277283 {"ldexp", math_ldexp},
278284 #if defined(LUA_COMPAT_LOG10)
279285 {"log10", math_log10},
@@ -291,6 +297,7 @@ static const luaL_Reg mathlib[] = { · 11 unmodified lines
291297 {"sqrt", math_sqrt},
292298 {"tanh", math_tanh},
293299 {"tan", math_tan},
300+ {"type", math_type},
294301 {NULL, NULL}
295302 };
296303