MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / math_fmod

Function math_fmod

extlibs/lua/src/lmathlib.c:117–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116
117static int math_fmod (lua_State *L) {
118 if (lua_isinteger(L, 1) && lua_isinteger(L, 2)) {
119 lua_Integer d = lua_tointeger(L, 2);
120 if ((lua_Unsigned)d + 1u <= 1u) { /* special cases: -1 or 0 */
121 luaL_argcheck(L, d != 0, 2, "zero");
122 lua_pushinteger(L, 0); /* avoid overflow with 0x80000... / -1 */
123 }
124 else
125 lua_pushinteger(L, lua_tointeger(L, 1) % d);
126 }
127 else
128 lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1),
129 luaL_checknumber(L, 2)));
130 return 1;
131}
132
133
134/*

Callers

nothing calls this directly

Calls 4

lua_pushintegerFunction · 0.85
lua_pushnumberFunction · 0.85
luaL_checknumberFunction · 0.85
lua_isintegerFunction · 0.70

Tested by

no test coverage detected