diff options
| author | 2026-10-14 16:21:48 +0330 | |
|---|---|---|
| committer | 2026-10-14 16:21:48 +0330 | |
| commit | f2ebb251efc5a528ce24c236e49b25fac225d881 (patch) | |
| tree | b62823245fe43a398ec9f6e6788c91290d33a985 /src | |
| parent | zc0: u*x, m*x, d*x are products when u, m or d is a visible local or global (... (diff) | |
rt.zdiv: INT_MIN / -1 is INT_MIN and % is 0 in software division too, so zc0 programs agree with spec 3.4.3
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/rt.zc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/rt.zc b/src/runtime/rt.zc index 4e52cb5..7018915 100644 --- a/src/runtime/rt.zc +++ b/src/runtime/rt.zc @@ -363,6 +363,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); |
