知行学院重新架构Golang版后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
391 B

package common
import (
"fmt"
"strconv"
"github.com/shopspring/decimal"
)
//float精度运算
func FloatAccuracyOperation(floatVal float64) (res float64) {
num, _ := strconv.ParseFloat(fmt.Sprintf("%.8f", floatVal), 64)
fmt.Println(num)
decimalValue := decimal.NewFromFloat(num)
decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
res, _ = decimalValue.Float64()
return
}