From 4391b45024127bd38f0c089363af7cad85f12e4b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 11:14:14 +0800 Subject: [PATCH] fix --- utils/format/price.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/format/price.go b/utils/format/price.go index 99063fde..f89e3f0a 100644 --- a/utils/format/price.go +++ b/utils/format/price.go @@ -6,8 +6,13 @@ import ( ) // 厘转美元 -func CentitoDollar(price int64) float64 { - str := fmt.Sprintf("%.3f", float64(price)/float64(1000)) +func CentitoDollar(price int64, remainFloatPoint ...uint) float64 { + s := "%.3f" + if len(remainFloatPoint) > 0 { + s = fmt.Sprintf("%%.%df", remainFloatPoint[0]) + } + fmt.Println(s) + str := fmt.Sprintf(s, float64(price)/float64(1000)) dollar, _ := strconv.ParseFloat(str, 64) return dollar }