Stdle #5 · 2026-06-11
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
1const std = @import("std");2pub fn main() void {3 const n: i32 = -7;4 std.debug.print("{d} {d}\n", .{ @divTrunc(n, 2), @divFloor(n, 2) });5}
Console output
Why
Zig has no bare `/` for runtime signed integers. You choose the rounding. `@divTrunc` truncates toward zero (-7/2 → -3), while `@divFloor` rounds toward negative infinity (-7/2 → -4). They only differ for negative operands.