1. float32 类型 转换成 string 类型 :
converted_string = ParseFloat(former_chart32, 32)
2. float64 类型 转换成 string 类型 :
converted_string = ParseFloat(former_chart64, 32)
3. string 类型 转换成 float32 类型 :
converted_chart32 = ParseFloat(former_string, 32)
4. string 类型 转换成 float64 类型 :
converted_chart64 = ParseFloat(former_string, 64)
//将float64转成精确的int64 func Wrap(num float64, retain int) int64 { return int64(num * math.Pow10(retain)) } //将int64恢复成正常的float64 func Unwrap(num int64, retain int) float64 { return float64(num) / math.Pow10(retain) } //精准float64 func WrapToFloat64(num float64, retain int) float64 { return num * math.Pow10(retain) } //精准int64 func UnwrapToInt64(num int64, retain int) int64 { return int64(Unwrap(num, retain)) }