Merge branch 'master' into v2.1
This commit is contained in:
@@ -75,11 +75,11 @@ int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b)
|
||||
uint32_t y, ua, ub;
|
||||
/* This must be checked before using this function. */
|
||||
lj_assertX(b != 0, "modulo with zero divisor");
|
||||
ua = a < 0 ? (uint32_t)-a : (uint32_t)a;
|
||||
ub = b < 0 ? (uint32_t)-b : (uint32_t)b;
|
||||
ua = a < 0 ? ~(uint32_t)a+1u : (uint32_t)a;
|
||||
ub = b < 0 ? ~(uint32_t)b+1u : (uint32_t)b;
|
||||
y = ua % ub;
|
||||
if (y != 0 && (a^b) < 0) y = y - ub;
|
||||
if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y;
|
||||
if (((int32_t)y^b) < 0) y = ~y+1u;
|
||||
return (int32_t)y;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user