From: Stefan Nilsson Date: Mon, 27 Dec 2010 18:12:10 +0000 (-0800) Subject: atof: added 'E' as valid token for exponent X-Git-Tag: weekly.2011-01-06~37 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=834fda37c5f4572250e76d8254ce80cdd81a06db;p=gostls13.git atof: added 'E' as valid token for exponent R=golang-dev, gri CC=golang-dev https://golang.org/cl/3827042 --- diff --git a/src/pkg/strconv/atof.go b/src/pkg/strconv/atof.go index 90ca7c4f9c..bcb138f7ad 100644 --- a/src/pkg/strconv/atof.go +++ b/src/pkg/strconv/atof.go @@ -107,7 +107,7 @@ func stringToDecimal(s string) (neg bool, d *decimal, trunc bool, ok bool) { // just be sure to move the decimal point by // a lot (say, 100000). it doesn't matter if it's // not the exact number. - if i < len(s) && s[i] == 'e' { + if i < len(s) && (s[i] == 'e' || s[i] == 'E') { i++ if i >= len(s) { return diff --git a/src/pkg/strconv/atof_test.go b/src/pkg/strconv/atof_test.go index 2277ff61a6..68c50bfbea 100644 --- a/src/pkg/strconv/atof_test.go +++ b/src/pkg/strconv/atof_test.go @@ -24,6 +24,7 @@ var atoftests = []atofTest{ {"1x", "0", os.EINVAL}, {"1.1.", "0", os.EINVAL}, {"1e23", "1e+23", nil}, + {"1E23", "1e+23", nil}, {"100000000000000000000000", "1e+23", nil}, {"1e-100", "1e-100", nil}, {"123456700", "1.234567e+08", nil},