Browse Source

update float64 to str

master
shenjiachi 1 day ago
parent
commit
28addfbf89
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      app/utils/convert.go

+ 4
- 1
app/utils/convert.go View File

@@ -271,7 +271,10 @@ func ByteToFloat64(bytes []byte) float64 {
}

func Float64ToStr(f float64) string {
return strconv.FormatFloat(f, 'f', 2, 64)
if f == float64(int64(f)) {
return strconv.FormatInt(int64(f), 10)
}
return fmt.Sprintf("%.2f", f)
}
func Float64ToStrPrec1(f float64) string {
return strconv.FormatFloat(f, 'f', 1, 64)


Loading…
Cancel
Save