You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff--gita/fastfloat/parse.gob/fastfloat/parse.goindex b37838d..b8a0bbe100644---a/fastfloat/parse.go+++b/fastfloat/parse.go
@@ -500,6+500,15 @@ funcParse(sstring) (float64, error) {
ifexpMinus {
exp=-exp
}
+ifd!=uint64(f) {
+// TODO comment.+// Fall back to standard parsing.+f, err:=strconv.ParseFloat(s, 64)
+iferr!=nil&&!math.IsInf(f, 0) {
+return0, fmt.Errorf("cannot parse exponent in %q: %s", s, err)
+ }
+returnf, nil+ }
f*=math.Pow10(int(exp))
ifi>=uint(len(s)) {
ifminus {
diff--gita/fastfloat/parse_test.gob/fastfloat/parse_test.goindex e4dfe2f..e06912a100644---a/fastfloat/parse_test.go+++b/fastfloat/parse_test.go
@@ -445,6+445,7 @@ funcTestParseSuccess(t*testing.T) {
f("-123e456", math.Inf(-1)) // too big exponentf("1e4", 1e4)
f("-1E-10", -1e-10)
+f("8.54E-4", 8.54e-4)
// Fractional + exponent partf("0.123e4", 0.123e4)
However, it does seem to go down the fallback route for some of the other test cases, which is not ideal and perhaps adversely affecting perf.
cc @valyala - would you be able to address this case? Or, let me know if my proposed fix is good enough and I can raise it as a PR. I believe a better option may exist but I'm not seeing it.
So far I've found mulitple apis I use which indeed respond with JSON number values like 8.54E-4. I would have to use MarshalTo to then parse it with strconv to get around it.
Hi
Is it possible to maintain equivalence with strconv for values like
8.54E-4
?The text was updated successfully, but these errors were encountered: