diff options
author | Mike Pall <mike> | 2022-12-22 00:52:04 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2022-12-22 00:52:04 +0100 |
commit | a04480e311f93d3ceb2f92549cad3fffa38250ef (patch) | |
tree | a9e2102ac93d2e358d6fd8735cdb8949409f746d /src/lj_vmmath.c | |
parent | 8625eee71f16a3a780ec92bc303c17456efc7fb3 (diff) | |
parent | 8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b (diff) | |
download | luajit-a04480e311f93d3ceb2f92549cad3fffa38250ef.tar.gz luajit-a04480e311f93d3ceb2f92549cad3fffa38250ef.tar.bz2 luajit-a04480e311f93d3ceb2f92549cad3fffa38250ef.zip |
Merge branch 'master' into v2.1
Diffstat (limited to 'src/lj_vmmath.c')
-rw-r--r-- | src/lj_vmmath.c | 6 |
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 |