Codebase list golang-github-vbauerster-mpb / 48a178f internal / percentage.go
48a178f

Tree @48a178f (Download .tar.gz)

percentage.go @48a178fraw · history · blame

package internal

// Percentage is a helper function, to calculate percentage.
func Percentage(total, current, width int64) int64 {
	if total <= 0 {
		return 0
	}
	p := float64(width*current) / float64(total)
	return int64(Round(p))
}