summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Nilsson <snilsson@nada.kth.se>2010-12-27 10:12:10 -0800
committerStefan Nilsson <snilsson@nada.kth.se>2010-12-27 10:12:10 -0800
commitdbd81c26b0027e765b50ea759ee97298b7586f18 (patch)
treea1e28f0df01ec19930f5d7e364a8a385b9e1f3c6
parentbf44242277c642b3439559f92c97e85ebccb8f2a (diff)
downloadgo-dbd81c26b0027e765b50ea759ee97298b7586f18.tar.gz
atof: added 'E' as valid token for exponent
R=golang-dev, gri CC=golang-dev http://codereview.appspot.com/3827042 Committer: Robert Griesemer <gri@golang.org>
-rw-r--r--src/pkg/strconv/atof.go2
-rw-r--r--src/pkg/strconv/atof_test.go1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/pkg/strconv/atof.go b/src/pkg/strconv/atof.go
index 90ca7c4f9..bcb138f7a 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 2277ff61a..68c50bfbe 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},