fix: 修复float32转换时精度丢失的问题。

main
NoahLan 1 year ago
parent 83920bfb2b
commit 1fe7b17eb1

@ -209,7 +209,9 @@ func ValToString(rv reflect.Value, defaultAsErr bool) (str string, err error) {
str = strconv.FormatBool(rv.Bool()) str = strconv.FormatBool(rv.Bool())
case reflect.String: case reflect.String:
str = rv.String() str = rv.String()
case reflect.Float32, reflect.Float64: case reflect.Float32:
str = strconv.FormatFloat(rv.Float(), 'f', -1, 32)
case reflect.Float64:
str = strconv.FormatFloat(rv.Float(), 'f', -1, 64) str = strconv.FormatFloat(rv.Float(), 'f', -1, 64)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
str = strconv.FormatInt(rv.Int(), 10) str = strconv.FormatInt(rv.Int(), 10)

Loading…
Cancel
Save