From 42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 7 Apr 2020 12:09:48 +0200 Subject: vendor c/image v5.4.2 Signed-off-by: Valentin Rothberg --- .../github.com/vbauerster/mpb/v5/internal/percentage.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 vendor/github.com/vbauerster/mpb/v5/internal/percentage.go (limited to 'vendor/github.com/vbauerster/mpb/v5/internal/percentage.go') diff --git a/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go new file mode 100644 index 000000000..7e261cb22 --- /dev/null +++ b/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go @@ -0,0 +1,15 @@ +package internal + +import "math" + +// Percentage is a helper function, to calculate percentage. +func Percentage(total, current int64, width int) float64 { + if total <= 0 { + return 0 + } + return float64(int64(width)*current) / float64(total) +} + +func PercentageRound(total, current int64, width int) float64 { + return math.Round(Percentage(total, current, width)) +} -- cgit v1.2.3-54-g00ecf