2023-06-02 11:24:58 +00:00
|
|
|
package format
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2023-09-15 06:52:36 +00:00
|
|
|
// 厘转美元
|
2023-09-21 10:21:31 +00:00
|
|
|
func CentitoDollar(price int64, remainFloatPoint ...uint) string {
|
|
|
|
s := "%0.3f"
|
2023-09-21 03:14:14 +00:00
|
|
|
if len(remainFloatPoint) > 0 {
|
2023-09-21 10:21:31 +00:00
|
|
|
s = fmt.Sprintf("%%0.%df", remainFloatPoint[0])
|
2023-09-21 03:14:14 +00:00
|
|
|
}
|
2023-09-21 10:21:31 +00:00
|
|
|
return fmt.Sprintf(s, float64(price)/float64(1000))
|
2023-06-02 11:24:58 +00:00
|
|
|
}
|
2023-09-21 04:11:15 +00:00
|
|
|
|
|
|
|
// 厘转美元
|
2023-09-21 06:26:14 +00:00
|
|
|
func CentitoDollarStr(price float64) string {
|
2023-09-21 04:11:15 +00:00
|
|
|
s := "%.2f"
|
2023-09-21 06:26:14 +00:00
|
|
|
return fmt.Sprintf(s, price/float64(1000))
|
2023-09-21 04:11:15 +00:00
|
|
|
}
|