diff options
Diffstat (limited to 'lib/std/math.zig')
| -rw-r--r-- | lib/std/math.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/math.zig b/lib/std/math.zig index 01cd68e0ed..725a71a4a6 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -1415,3 +1415,8 @@ test "boolMask" { try runTest(); comptime try runTest(); } + +/// Return the mod of `num` with the smallest integer type +pub fn comptimeMod(num: anytype, denom: comptime_int) IntFittingRange(0, denom - 1) { + return @intCast(IntFittingRange(0, denom - 1), @mod(num, denom)); +} |
