mirror of
https://github.com/luxfi/formatting.git
synced 2026-10-30 16:55:53 +00:00
18 lines
328 B
Go
18 lines
328 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package formatting
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
)
|
|
|
|
func IntFormat(maxValue int) string {
|
|
log := 1
|
|
if maxValue > 0 {
|
|
log = int(math.Ceil(math.Log10(float64(maxValue + 1))))
|
|
}
|
|
return fmt.Sprintf("%%0%dd", log)
|
|
}
|