#How to left pad number so it prints `" 1"` instead of `"1"`

1 messages · Page 1 of 1 (latest)

sharp galleon
#

I am stupid and don't understand std.fmt.format docs
{d: >2} tried {d:>2} but it keeps printing "+1"

std.debug.print("{d: >2}", .{ 1 });
ebon ginkgo
#
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?
sharp galleon
#

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?
ebon ginkgo
#

looking at the implementation, it seems like the moment a (non-zero) width is defined, a + will be inserted