fusenapi/utils/format/price.go
laodaming f767af9a7f fix
2023-09-21 18:22:55 +08:00

21 lines
395 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 := "%0.2f"
return fmt.Sprintf(s, price/float64(1000))
}