github.com/MetalBlockchain/metalgo@v1.11.9/utils/formatting/int_format.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package formatting 5 6 import ( 7 "fmt" 8 "math" 9 ) 10 11 func IntFormat(maxValue int) string { 12 log := 1 13 if maxValue > 0 { 14 log = int(math.Ceil(math.Log10(float64(maxValue + 1)))) 15 } 16 return fmt.Sprintf("%%0%dd", log) 17 }