Files
PandaX/kit/utils/float_to_f.go
lixxxww 0ff66b9d43 提交kit/utils
Signed-off-by: lixxxww <941403820@qq.com>
2024-01-23 11:57:42 +00:00

27 lines
454 B
Go

package utils
import (
"fmt"
"strconv"
)
func ParseFloat2F(value float64) float64 {
newValue, err := strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
if err != nil {
fmt.Println("保留2位小数, 转换float出错")
return value
}
return newValue
}
func ParseStringToInt64(value string) int64 {
newValue, err := strconv.ParseInt(value, 10, 64)
if err != nil {
fmt.Println("string转换int64出错")
return 0
}
return newValue
}