MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaV_mod

Function luaV_mod

freebsd/contrib/openzfs/module/lua/lvm.c:392–404  ·  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

390** about luaV_div.)
391*/
392static lua_Number luaV_mod (lua_State *L, lua_Number m, lua_Number n) {
393 if ((lua_Unsigned)(n) + 1u <= 1u) { /* special cases: -1 or 0 */
394 if (n == 0)
395 luaG_runerror(L, "attempt to perform 'n%%0'");
396 return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
397 }
398 else {
399 lua_Number r = m % n;
400 if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */
401 r += n; /* correct result for different rounding */
402 return r;
403 }
404}
405
406/*
407 * End patch from 5.3.2

Callers 1

luaV_arithFunction · 0.85

Calls 1

luaG_runerrorFunction · 0.70

Tested by

no test coverage detected