summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-02-01 16:14:22 -0800
committerRobert Griesemer <gri@golang.org>2010-02-01 16:14:22 -0800
commit9f6cb4c7f82b20cebe227a5fdee0810dba45e9ab (patch)
tree2effea873f0f863169080f22dd45ca0a358c428c
parent6a6afdf718bfe0b3894490f62326e240eac2f9bb (diff)
downloadgolang-9f6cb4c7f82b20cebe227a5fdee0810dba45e9ab.tar.gz
Corrected broken assertion.
Fixes issue 571. R=rsc CC=golang-dev http://codereview.appspot.com/198045
-rw-r--r--src/pkg/bignum/bignum.go6
-rw-r--r--src/pkg/bignum/bignum_test.go6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/pkg/bignum/bignum.go b/src/pkg/bignum/bignum.go
index ee7d45ba6..485583199 100644
--- a/src/pkg/bignum/bignum.go
+++ b/src/pkg/bignum/bignum.go
@@ -565,16 +565,18 @@ func divmod(x, y []digit2) ([]digit2, []digit2) {
t := c + digit(x[i+j]) - digit(y[j])*q
c, x[i+j] = digit(int64(t)>>_W2), digit2(t&_M2) // requires arithmetic shift!
}
+ x[k] = digit2((c + digit(x[k])) & _M2)
// correct if trial digit was too large
- if c+digit(x[k]) != 0 {
+ if x[k] != 0 {
// add y
c := digit(0)
for j := 0; j < m; j++ {
t := c + digit(x[i+j]) + digit(y[j])
c, x[i+j] = t>>_W2, digit2(t&_M2)
}
- assert(c+digit(x[k]) == 0)
+ x[k] = digit2((c + digit(x[k])) & _M2)
+ assert(x[k] == 0)
// correct trial digit
q--
}
diff --git a/src/pkg/bignum/bignum_test.go b/src/pkg/bignum/bignum_test.go
index 532fc9740..ade72dd1b 100644
--- a/src/pkg/bignum/bignum_test.go
+++ b/src/pkg/bignum/bignum_test.go
@@ -663,3 +663,9 @@ func TestNatPop(t *testing.T) {
test(i, nat_one.Shl(i).Sub(nat_one).Pop() == i)
}
}
+
+
+func TestIssue571(t *testing.T) {
+ const min_float = "4.940656458412465441765687928682213723651e-324"
+ RatFromString(min_float, 10) // this must not crash
+}