aboutsummaryrefslogtreecommitdiff
path: root/src/lj_vmmath.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lj_vmmath.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c
index d0febd81..4fa79ae4 100644
--- a/src/lj_vmmath.c
+++ b/src/lj_vmmath.c
@@ -75,11 +75,11 @@ int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b)
75 uint32_t y, ua, ub; 75 uint32_t y, ua, ub;
76 /* This must be checked before using this function. */ 76 /* This must be checked before using this function. */
77 lj_assertX(b != 0, "modulo with zero divisor"); 77 lj_assertX(b != 0, "modulo with zero divisor");
78 ua = a < 0 ? (uint32_t)-a : (uint32_t)a; 78 ua = a < 0 ? ~(uint32_t)a+1u : (uint32_t)a;
79 ub = b < 0 ? (uint32_t)-b : (uint32_t)b; 79 ub = b < 0 ? ~(uint32_t)b+1u : (uint32_t)b;
80 y = ua % ub; 80 y = ua % ub;
81 if (y != 0 && (a^b) < 0) y = y - ub; 81 if (y != 0 && (a^b) < 0) y = y - ub;
82 if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; 82 if (((int32_t)y^b) < 0) y = ~y+1u;
83 return (int32_t)y; 83 return (int32_t)y;
84} 84}
85#endif 85#endif