Skip to content

Commit

Permalink
Apply smart roudning to percent and times
Browse files Browse the repository at this point in the history
  • Loading branch information
cgbur committed Aug 20, 2023
1 parent 8676c49 commit e805d37
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const usage_text: []const u8 =
\\Calculate the percent change between numbers.
\\
\\Arguments:
\\ numbers... : A sequence of numbers for which the percent change is to be calculated.
\\ numbers... : A sequence of numbers for which the differences are to be calculated.
\\
\\Special Arguments:
\\ - : Reads input from stdin.
Expand Down Expand Up @@ -212,12 +212,12 @@ fn makeRow(allocator: Allocator, prev: f32, cur: f32, raw: bool) !DiffItem {

const percent = try std.fmt.allocPrint(allocator, "{[perc]d:.[diff_prec]}", .{
.perc = percent_diff,
.diff_prec = numberPrecision(percent_diff),
.diff_prec = sizeFormatPrecision(percent_diff),
});

const times = try std.fmt.allocPrint(allocator, "{[times]d:.[times_prec]}", .{
.times = times_diff,
.times_prec = numberPrecision(times_diff),
.times_prec = sizeFormatPrecision(times_diff),
});

var previous: []const u8 = undefined;
Expand Down

0 comments on commit e805d37

Please sign in to comment.