]> Cypherpunks repositories - gostls13.git/commitdiff
atof: added 'E' as valid token for exponent
authorStefan Nilsson <snilsson@nada.kth.se>
Mon, 27 Dec 2010 18:12:10 +0000 (10:12 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 27 Dec 2010 18:12:10 +0000 (10:12 -0800)
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/3827042

src/pkg/strconv/atof.go
src/pkg/strconv/atof_test.go

index 90ca7c4f9cf8c009b73aea7868a4ccea1a4a7a7f..bcb138f7ad2ea5f07a631569336654e4796ffea4 100644 (file)
@@ -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
index 2277ff61a62652a2bf3ed08d5999224e2895e5f1..68c50bfbead64683f7119c55d5f3f7608ab72300 100644 (file)
@@ -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},