math.go
276 字节
package utils
import (
"fmt"
"math"
"strconv"
)
func decimal(value float64) float64 {
return math.Trunc(value*1e1+0.5) * 1e-1
}
func Decimal(value float64) float64 {
value = decimal(value)
value, _ = strconv.ParseFloat(fmt.Sprintf("%.1f", value), 64)
return value
}