]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: trim trailing zeros before hex printing
authorDave Cheney <dave@cheney.net>
Tue, 2 Jun 2015 03:08:59 +0000 (13:08 +1000)
committerRobert Griesemer <gri@golang.org>
Wed, 3 Jun 2015 22:06:04 +0000 (22:06 +0000)
m was being resliced as the result of looking for the first
non zero word of the mantissa, however m was not used later
in printing.

Spotted by Gordon Klaus, https://groups.google.com/forum/#!topic/golang-nuts/MdDLbvOjb4o

Change-Id: Ifbebb51ea5e0d86cb8e0422eb184b8634639a733
Reviewed-on: https://go-review.googlesource.com/10604
Reviewed-by: Robert Griesemer <gri@golang.org>
src/math/big/ftoa.go

index 13bb26f0d2ac8cd74d516d98ce4f58c1608bf57a..5c5f2cea460cc87a211e527d24f218f820c12a11 100644 (file)
@@ -289,7 +289,7 @@ func (x *Float) fmtP(buf []byte) []byte {
        m = m[i:]
 
        buf = append(buf, "0x."...)
-       buf = append(buf, strings.TrimRight(x.mant.hexString(), "0")...)
+       buf = append(buf, strings.TrimRight(m.hexString(), "0")...)
        buf = append(buf, 'p')
        if x.exp >= 0 {
                buf = append(buf, '+')