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)) }