21 lines
395 B
Go
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))
|
|
}
|