MCPcopy Create free account
hub / github.com/DFHack/dfhack / math_fmod

Function math_fmod

depends/lua/src/lmathlib.c:127–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125
126
127static int math_fmod (lua_State *L) {
128 if (lua_isinteger(L, 1) && lua_isinteger(L, 2)) {
129 lua_Integer d = lua_tointeger(L, 2);
130 if ((lua_Unsigned)d + 1u <= 1u) { /* special cases: -1 or 0 */
131 luaL_argcheck(L, d != 0, 2, "zero");
132 lua_pushinteger(L, 0); /* avoid overflow with 0x80000... / -1 */
133 }
134 else
135 lua_pushinteger(L, lua_tointeger(L, 1) % d);
136 }
137 else
138 lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1),
139 luaL_checknumber(L, 2)));
140 return 1;
141}
142
143
144/*

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected