File: percentage.go

package info (click to toggle)
golang-github-pterm-pterm 0.12.79-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,640 kB
  • sloc: makefile: 4
file content (13 lines) | stat: -rw-r--r-- 308 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
package internal

import "math"

// Percentage calculates percentage.
func Percentage(total, current float64) float64 {
	return (current / total) * 100
}

// PercentageRound returns a rounded Percentage.
func PercentageRound(total, current float64) float64 {
	return math.Round(Percentage(total, current))
}