math.go 425 字节
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
}

func DecimalToNumber(value float64) float64 {
	value = decimal(value)
	value, _ = strconv.ParseFloat(fmt.Sprintf("%.f", value), 64)
	return value
}