MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / luaV_mod

Function luaV_mod

Dependencies/lua/src/lvm.c:745–757  ·  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

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

Callers 1

intarithFunction · 0.85

Calls 1

luaG_runerrorFunction · 0.85

Tested by

no test coverage detected