summaryrefslogtreecommitdiff
path: root/src/strconv/atof.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-10-28 09:12:20 -0400
committerCherry Zhang <cherryyz@google.com>2020-10-28 09:12:20 -0400
commita16e30d162c1c7408db7821e7b9513cefa09c6ca (patch)
treeaf752ba9ba44c547df39bb0af9bff79f610ba9d5 /src/strconv/atof.go
parent91e4d2d57bc341dd82c98247117114c851380aef (diff)
parentcf6cfba4d5358404dd890f6025e573a4b2156543 (diff)
downloadgo-git-dev.link.tar.gz
[dev.link] all: merge branch 'master' into dev.linkdev.link
Clean merge. Change-Id: Ia7b2808bc649790198d34c226a61d9e569084dc5
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.