]> Cypherpunks repositories - gostls13.git/commitdiff
xml: differentiate between float32 and float64 for marshalSimple
authorVega Garcia Luis Alfonso <vegacom@gmail.com>
Mon, 28 Jan 2013 17:54:27 +0000 (12:54 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 28 Jan 2013 17:54:27 +0000 (12:54 -0500)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7235045

src/pkg/encoding/xml/marshal.go

index 383fb26b04396c8e0e2036e5e41e3cbe3c6b57bd..aacb50c9cfcb3eefb3c38c7f13378b86e3bb9661 100644 (file)
@@ -241,7 +241,7 @@ func (p *printer) marshalSimple(typ reflect.Type, val reflect.Value) error {
        case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
                p.WriteString(strconv.FormatUint(val.Uint(), 10))
        case reflect.Float32, reflect.Float64:
-               p.WriteString(strconv.FormatFloat(val.Float(), 'g', -1, 64))
+               p.WriteString(strconv.FormatFloat(val.Float(), 'g', -1, val.Type().Bits()))
        case reflect.String:
                // TODO: Add EscapeString.
                Escape(p, []byte(val.String()))