Commit a61293a2 by zhengqiuyun86

元与分的转换

parent 10d0724c
package util
import (
"fmt"
"github.com/shopspring/decimal"
"strconv"
)
......@@ -42,3 +43,13 @@ func DivideFloat64(a *float64, b *float64) *float64 {
r, _ := decimal.NewFromFloat(*a).Div(decimal.NewFromFloat(*b)).Float64()
return &r
}
func yuanToFen(t float64) int64 {
value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", *MultiplyFloat64(&t, Addr(float64(100)))), 64)
return int64(value + 0.5)
}
func fenToYuan(t int64) float64 {
value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", *DivideFloat64(Addr(float64(t)), Addr(float64(100)))), 64)
return value
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment