go-common/app/interface/bbq/app-bbq/model/util.go
2019-04-22 18:49:16 +08:00

21 lines
350 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"math"
"strconv"
)
// CalNum2SufStr int64转换带后缀字符串K,W,E
func CalNum2SufStr(n int64) string {
var f float64
var s string
if n > 1000 {
f = float64(n) / 1000
s = strconv.FormatFloat(math.Ceil(f), 'f', 0, 64) + "k"
} else {
f = float64(n)
s = strconv.FormatFloat(f, 'f', 0, 64)
}
return s
}