2
0

support scientific notation big floats

This commit is contained in:
Eshton Robateau
2023-11-24 07:23:52 +08:00
committed by Jack Christensen
parent 913e4c8487
commit 95b2f85e60
2 changed files with 56 additions and 36 deletions
+8
View File
@@ -759,6 +759,14 @@ func (scanPlanTextAnyToNumericScanner) Scan(src []byte, dst any) error {
return scanner.ScanNumeric(Numeric{InfinityModifier: NegativeInfinity, Valid: true})
}
if strings.ContainsAny(string(src), "eE") {
if bigF, ok := new(big.Float).SetString(string(src)); ok {
smallF, _ := bigF.Float64()
src = []byte(strconv.FormatFloat(smallF, 'f', -1, int(bigF.Prec())))
}
}
num, exp, err := parseNumericString(string(src))
if err != nil {
return err