fusenapi/utils/format/price.go
laodaming 584cb5d531 fix
2023-09-21 18:21:31 +08:00

21 lines
394 B
Go

package format
import (
"fmt"
)
// 厘转美元
func CentitoDollar(price int64, remainFloatPoint ...uint) string {
s := "%0.3f"
if len(remainFloatPoint) > 0 {
s = fmt.Sprintf("%%0.%df", remainFloatPoint[0])
}
return fmt.Sprintf(s, float64(price)/float64(1000))
}
// 厘转美元
func CentitoDollarStr(price float64) string {
s := "%.2f"
return fmt.Sprintf(s, price/float64(1000))
}