1234567891011121314 |
- package money
- import "github.com/shopspring/decimal"
- func Yuan2Fen(price float64) int64 {
- return decimal.NewFromFloat(price).Mul(decimal.New(1, 2)).IntPart()
- }
- func Fen2Yuan(price uint64) float64 {
- //分除以100得到元
- d := decimal.New(1, 2)
- result, _ := decimal.NewFromInt(int64(price)).DivRound(d, 2).Float64()
- return result
- }
|