aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math/big/floatconv_test.go4
-rw-r--r--src/math/big/ftoa.go3
2 files changed, 5 insertions, 2 deletions
diff --git a/src/math/big/floatconv_test.go b/src/math/big/floatconv_test.go
index c6c6ba63e5..3aa6834143 100644
--- a/src/math/big/floatconv_test.go
+++ b/src/math/big/floatconv_test.go
@@ -536,6 +536,10 @@ func TestFloatText(t *testing.T) {
{"-8191.53125", ToNegativeInf, 53, 'x', 4, "-0x1.fff9p+12"},
{"8191.53125", ToPositiveInf, 53, 'x', 4, "0x1.fff9p+12"},
{"-8191.53125", ToPositiveInf, 53, 'x', 4, "-0x1.fff8p+12"},
+
+ // issue 34343
+ {"0x.8p-2147483648", ToNearestEven, 4, 'p', -1, "0x.8p-2147483648"},
+ {"0x.8p-2147483648", ToNearestEven, 4, 'x', -1, "0x1p-2147483649"},
} {
f, _, err := ParseFloat(test.x, 0, test.prec, ToNearestEven)
if err != nil {
diff --git a/src/math/big/ftoa.go b/src/math/big/ftoa.go
index 6cae63ed09..5506e6e425 100644
--- a/src/math/big/ftoa.go
+++ b/src/math/big/ftoa.go
@@ -384,7 +384,7 @@ func (x *Float) fmtX(buf []byte, prec int) []byte {
case w > n:
m = nat(nil).shr(m, w-n)
}
- exp := x.exp - 1
+ exp64 := int64(x.exp) - 1 // avoid wrap-around
hm := m.utoa(16)
if debugFloat && hm[0] != '1' {
@@ -397,7 +397,6 @@ func (x *Float) fmtX(buf []byte, prec int) []byte {
}
buf = append(buf, 'p')
- exp64 := int64(exp)
if exp64 >= 0 {
buf = append(buf, '+')
} else {