|
@@ -304,3 +304,17 @@ func StrToUint(str string) uint {
|
|
|
intValue, _ := strconv.Atoi(str)
|
|
|
return uint(intValue)
|
|
|
}
|
|
|
+
|
|
|
+func FloatToStr4(f float64, len int) string {
|
|
|
+ // 如果格式标记为 'e','E'和'f',则 prec 表示小数点后的数字位数
|
|
|
+ // 如果格式标记为 'g','G',则 prec 表示总的数字位数(整数部分+小数部分)
|
|
|
+ //func FormatFloat(f float64, fmt byte, prec, bitSize int) string
|
|
|
+ //f := 100.12345678901234567890123456789
|
|
|
+ //zaplog.LoggerS.Info(strconv.FormatFloat(f, 'f', 5, 64))
|
|
|
+ // 100.12346
|
|
|
+ //zaplog.LoggerS.Info(strconv.FormatFloat(f, 'g', 5, 64))
|
|
|
+ // 100.12
|
|
|
+ //zaplog.LoggerS.Info(strconv.FormatFloat(f, 'G', 5, 64))
|
|
|
+ // 100.12
|
|
|
+ return strconv.FormatFloat(f, 'f', len, 64)
|
|
|
+}
|