21 lines
350 B
Go
Raw Permalink Normal View History

2019-04-22 02:59:20 +00:00
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
}