MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaV_mod

Function luaV_mod

third-party/lua-5.4.6/src/lvm.c:748–760  ·  view source on GitHub ↗

** Integer modulus; return 'm % n'. (Assume that C '%' with ** negative operands follows C99 behavior. See previous comment ** about luaV_idiv.) */

Source from the content-addressed store, hash-verified

746** about luaV_idiv.)
747*/
748lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
749 if (l_unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */
750 if (n == 0)
751 luaG_runerror(L, "attempt to perform 'n%%0'");
752 return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
753 }
754 else {
755 lua_Integer r = m % n;
756 if (r != 0 && (r ^ n) < 0) /* 'm/n' would be non-integer negative? */
757 r += n; /* correct result for different rounding */
758 return r;
759 }
760}
761
762
763/*

Callers 1

intarithFunction · 0.70

Calls 1

luaG_runerrorFunction · 0.70

Tested by

no test coverage detected