aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Nilsson <snilsson@nada.kth.se>2010-12-27 10:12:10 -0800
committerRobert Griesemer <gri@golang.org>2010-12-27 10:12:10 -0800
commit834fda37c5f4572250e76d8254ce80cdd81a06db (patch)
treec1185cfc33f27a73f02415511a690cbc384296df
parent33145c48682523177ac1cf62ee6b86eed680fffa (diff)
downloadgo-834fda37c5f4572250e76d8254ce80cdd81a06db.tar.gz
go-834fda37c5f4572250e76d8254ce80cdd81a06db.zip
atof: added 'E' as valid token for exponent
R=golang-dev, gri CC=golang-dev https://golang.org/cl/3827042
-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 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},