From a670f5519568b893f17e1ea06a0646e4726e21ca Mon Sep 17 00:00:00 2001 From: fdfdjfk3 <96026401+fdfdjfk3@users.noreply.github.com> Date: Mon, 2 Sep 2024 04:21:59 -0700 Subject: [PATCH] std.fmt.fmtIntSize*: document when precision is ignored --- lib/std/fmt.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 7f323248cf..dad39025b6 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -950,13 +950,13 @@ fn formatSizeImpl(comptime base: comptime_int) type { } }; } - const formatSizeDec = formatSizeImpl(1000).formatSizeImpl; const formatSizeBin = formatSizeImpl(1024).formatSizeImpl; /// Return a Formatter for a u64 value representing a file size. /// This formatter represents the number as multiple of 1000 and uses the SI /// measurement units (kB, MB, GB, ...). +/// Format option `precision` is ignored when `value` is less than 1kB pub fn fmtIntSizeDec(value: u64) std.fmt.Formatter(formatSizeDec) { return .{ .data = value }; } @@ -964,6 +964,7 @@ pub fn fmtIntSizeDec(value: u64) std.fmt.Formatter(formatSizeDec) { /// Return a Formatter for a u64 value representing a file size. /// This formatter represents the number as multiple of 1024 and uses the IEC /// measurement units (KiB, MiB, GiB, ...). +/// Format option `precision` is ignored when `value` is less than 1KiB pub fn fmtIntSizeBin(value: u64) std.fmt.Formatter(formatSizeBin) { return .{ .data = value }; }