]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: fix silly bug in Int64 accessor
authorRobert Griesemer <gri@golang.org>
Fri, 13 Mar 2015 19:59:56 +0000 (12:59 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 13 Mar 2015 20:14:57 +0000 (20:14 +0000)
Change-Id: If335d45ea1ab6c8aeeb47515f97680e2c1d651f3
Reviewed-on: https://go-review.googlesource.com/7522
Reviewed-by: Alan Donovan <adonovan@google.com>
src/math/big/float.go
src/math/big/float_test.go

index 778cc20da5c1139ce5faf7d7791f58400b2482cd..feca6921a078f938d7ea22cf13a31db2584bc560 100644 (file)
@@ -835,7 +835,7 @@ func (x *Float) Int64() (int64, Accuracy) {
                        if x.neg {
                                i = -i
                        }
-                       if x.MinPrec() <= 63 {
+                       if x.MinPrec() <= uint(x.exp) {
                                return i, Exact
                        }
                        return i, acc // x truncated
index dca78a84c53e85b6487cbeb34293dd69079997b8..cc38f68436f9cae5e12ab56052bbfd3441ccfe94 100644 (file)
@@ -808,12 +808,14 @@ func TestFloatInt64(t *testing.T) {
                {"-12345.000000000000000000001", -12345, Above},
                {"-12345.0", -12345, Exact},
                {"-1.000000000000000000001", -1, Above},
+               {"-1.5", -1, Above},
                {"-1", -1, Exact},
                {"-1e-1000", 0, Above},
                {"0", 0, Exact},
                {"1e-1000", 0, Below},
                {"1", 1, Exact},
                {"1.000000000000000000001", 1, Below},
+               {"1.5", 1, Below},
                {"12345.0", 12345, Exact},
                {"12345.000000000000000000001", 12345, Below},
                {"9223372036854775807", 9223372036854775807, Exact},