aboutsummaryrefslogtreecommitdiff
path: root/src/strconv/atof.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/strconv/atof.go')
-rw-r--r--src/strconv/atof.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/strconv/atof.go b/src/strconv/atof.go
index 901f27afff..e61eeab1c3 100644
--- a/src/strconv/atof.go
+++ b/src/strconv/atof.go
@@ -581,6 +581,8 @@ func atof32(s string) (f float32, n int, err error) {
if !trunc {
if f, ok := atof32exact(mantissa, exp, neg); ok {
return f, n, nil
+ } else if f, ok = eiselLemire32(mantissa, exp, neg); ok {
+ return f, n, nil
}
}
// Try another fast path.
@@ -624,10 +626,13 @@ func atof64(s string) (f float64, n int, err error) {
}
if optimize {
- // Try pure floating-point arithmetic conversion.
+ // Try pure floating-point arithmetic conversion, and if that fails,
+ // the Eisel-Lemire algorithm.
if !trunc {
if f, ok := atof64exact(mantissa, exp, neg); ok {
return f, n, nil
+ } else if f, ok = eiselLemire64(mantissa, exp, neg); ok {
+ return f, n, nil
}
}
// Try another fast path.