MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / CalculatePercentageInt

Function CalculatePercentageInt

internal/ui/utils/formatting.go:161–167  ·  view source on GitHub ↗

CalculatePercentageInt safely calculates percentage from used and total int64 values Returns 0.0 if total is 0 to avoid division by zero.

(used, total int64)

Source from the content-addressed store, hash-verified

159// CalculatePercentageInt safely calculates percentage from used and total int64 values
160// Returns 0.0 if total is 0 to avoid division by zero.
161func CalculatePercentageInt(used, total int64) float64 {
162 if total <= 0 {
163 return 0.0
164 }
165
166 return (float64(used) / float64(total)) * 100
167}
168
169// TrimTrailingWhitespace removes all trailing whitespace (spaces, tabs, newlines, carriage returns) from the end of the string.
170func TrimTrailingWhitespace(s string) string {

Callers 2

UpdateMethod · 0.92
UpdateMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected