From 84ae54fbe64a15301317716e7f901d81585332d5 Mon Sep 17 00:00:00 2001 From: IOKG04 Date: Tue, 22 Jul 2025 13:15:43 +0200 Subject: [PATCH] `@rem()` and `@mod()` take `denominator != 0`, not just `denominator > 0` https://github.com/ziglang/zig/issues/23635 I also added tests for `@rem()` with `denominator < 0` cause there were none before I hope I added them in the correct place, if not I can change it ofc --- doc/langref.html.in | 4 ++-- test/behavior/math.zig | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 348f35444d..139c19211e 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -5179,7 +5179,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}

Modulus division. For unsigned integers this is the same as - {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator > 0{#endsyntax#}, otherwise the + {#syntax#}numerator % denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#}, otherwise the operation will result in a {#link|Remainder Division by Zero#} when runtime safety checks are enabled.