math.go 446 字节
package utils

import (
	"github.com/shopspring/decimal"
	"math"
)

func decimal1(value float64) float64 {
	return math.Trunc(value*1e1+0.5) * 1e-1
}

func Round(value float64, places int32) float64 {
	quantity := decimal.NewFromFloat(value)
	d := quantity.Round(places)
	rsp, _ := d.Float64()
	return rsp
}

func Decimal(value float64) float64 {
	return Round(value, 2)
}

func DecimalToNumber(value float64) float64 {
	return Round(value, 2)
}