aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/rt.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 17:12:04 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 17:12:04 +0330
commitee6925c12b3275c05f5943ef7785fa1d958de499 (patch)
tree7f7a1f55e4f91ca0f30a85a868d1c20631e5f344 /src/runtime/rt.zc
parentwip: bench wraps bench.sh (diff)
parentmerge work/spec: appendix b round, zc0umd rewrite (diff)
Merge branch 'main' into work/bench
Diffstat (limited to 'src/runtime/rt.zc')
-rw-r--r--src/runtime/rt.zc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/rt.zc b/src/runtime/rt.zc
index f1414e4..44f3570 100644
--- a/src/runtime/rt.zc
+++ b/src/runtime/rt.zc
@@ -377,6 +377,7 @@ int zudiv(int n, int dv) {
int zdiv(int a, int b) {
word s = 0; int q;
if (b == 0) { zrem = a; return 0; }
+ if (b == 0 - 1) { zrem = 0; return 0 - a; } // INT_MIN / -1 is INT_MIN and its remainder 0 (spec 3.4.3); zudiv can't take 2^63
if (a < 0) { a = 0 - a; s = 1; }
if (b < 0) { b = 0 - b; s = s ^ 1; }
q = zudiv(a, b);