MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / luaV_mod

Function luaV_mod

libraries/AP_Scripting/lua/src/lvm.c:576–588  ·  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

574** about luaV_div.)
575*/
576lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
577 if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */
578 if (n == 0)
579 luaG_runerror(L, "attempt to perform 'n%%0'");
580 return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
581 }
582 else {
583 lua_Integer r = m % n;
584 if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */
585 r += n; /* correct result for different rounding */
586 return r;
587 }
588}
589
590
591/* 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