#How to left pad number so it prints `" 1"` instead of `"1"`
1 messages · Page 1 of 1 (latest)
const std = @import("std");
pub fn main() !void {
std.debug.print("{d: >2}", .{1});
}
$ zig run temp.zig
1
```you must have an issue somewhere else then?
It seems it prints + because I am using i16 variable type.
const std = @import("std");
pub fn main() !void {
std.debug.print("`{d: >2}`", .{@as(i16, 1)});
// prints: `+1`
}
``` Is there any way to prints it the same way despite the type?
looking at the implementation, it seems like the moment a (non-zero) width is defined, a + will be inserted