MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / luaV_mod

Function luaV_mod

ThirdParty/lua/lua/lvm.c:455–467  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

453** about luaV_div.)
454*/
455lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
456 if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */
457 if (n == 0)
458 luaG_runerror(L, "attempt to perform 'n%%0'");
459 return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
460 }
461 else {
462 lua_Integer r = m % n;
463 if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */
464 r += n; /* correct result for different rounding */
465 return r;
466 }
467}
468
469
470/* number of bits in an integer */

Callers 2

luaV_executeFunction · 0.85
intarithFunction · 0.85

Calls 1

luaG_runerrorFunction · 0.85

Tested by

no test coverage detected