diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-13 05:11:45 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-13 05:11:45 +0000 |
commit | df4aa89a5e7acb315655f193e7f549e8d32367e2 (patch) | |
tree | eb5eccc07097c5fcf940967f33ab84a7d47c96fe /libgo/go/math | |
parent | f83fa0bf8f411697ec908cfa86ee6faf4cd9c476 (diff) |
libgo: Update to weekly.2011-12-22.
From-SVN: r183150
Diffstat (limited to 'libgo/go/math')
-rw-r--r-- | libgo/go/math/all_test.go | 4 | ||||
-rw-r--r-- | libgo/go/math/big/int_test.go | 7 | ||||
-rw-r--r-- | libgo/go/math/big/nat.go | 6 | ||||
-rw-r--r-- | libgo/go/math/big/nat_test.go | 3 | ||||
-rw-r--r-- | libgo/go/math/sin.go | 1 |
5 files changed, 18 insertions, 3 deletions
diff --git a/libgo/go/math/all_test.go b/libgo/go/math/all_test.go index 0a3cb0315d2..101c8dd85b4 100644 --- a/libgo/go/math/all_test.go +++ b/libgo/go/math/all_test.go @@ -22,6 +22,7 @@ var vf = []float64{ 1.8253080916808550e+00, -8.6859247685756013e+00, } + // The expected results below were computed by the high precision calculators // at http://keisan.casio.com/. More exact input values (array vf[], above) // were obtained by printing them with "%.26f". The answers were calculated @@ -159,6 +160,7 @@ var cos = []float64{ -2.517729313893103197176091e-01, -7.39241351595676573201918e-01, } + // Results for 100000 * Pi + vf[i] var cosLarge = []float64{ 2.634752141185559426744e-01, @@ -514,6 +516,7 @@ var sin = []float64{ 9.6778633541687993721617774e-01, -6.734405869050344734943028e-01, } + // Results for 100000 * Pi + vf[i] var sinLarge = []float64{ -9.646661658548936063912e-01, @@ -563,6 +566,7 @@ var tan = []float64{ -3.843885560201130679995041e+00, 9.10988793377685105753416e-01, } + // Results for 100000 * Pi + vf[i] var tanLarge = []float64{ -3.66131656475596512705e+00, diff --git a/libgo/go/math/big/int_test.go b/libgo/go/math/big/int_test.go index aa7c1949549..9c4b7301874 100644 --- a/libgo/go/math/big/int_test.go +++ b/libgo/go/math/big/int_test.go @@ -9,6 +9,7 @@ import ( "encoding/gob" "encoding/hex" "fmt" + "math/rand" "testing" "testing/quick" ) @@ -1405,3 +1406,9 @@ func TestIntGobEncoding(t *testing.T) { } } } + +func TestIssue2607(t *testing.T) { + // This code sequence used to hang. + n := NewInt(10) + n.Rand(rand.New(rand.NewSource(9)), n) +} diff --git a/libgo/go/math/big/nat.go b/libgo/go/math/big/nat.go index ead1a881a6a..69681ae2d64 100644 --- a/libgo/go/math/big/nat.go +++ b/libgo/go/math/big/nat.go @@ -1196,12 +1196,16 @@ func (x nat) powersOfTwoDecompose() (q nat, k int) { // random creates a random integer in [0..limit), using the space in z if // possible. n is the bit length of limit. func (z nat) random(rand *rand.Rand, limit nat, n int) nat { + if alias(z, limit) { + z = nil // z is an alias for limit - cannot reuse + } + z = z.make(len(limit)) + bitLengthOfMSW := uint(n % _W) if bitLengthOfMSW == 0 { bitLengthOfMSW = _W } mask := Word((1 << bitLengthOfMSW) - 1) - z = z.make(len(limit)) for { for i := range z { diff --git a/libgo/go/math/big/nat_test.go b/libgo/go/math/big/nat_test.go index e3c6552d9fb..25e39273c0c 100644 --- a/libgo/go/math/big/nat_test.go +++ b/libgo/go/math/big/nat_test.go @@ -5,7 +5,6 @@ package big import ( - "fmt" "io" "strings" "testing" @@ -402,7 +401,7 @@ func ScanHelper(b *testing.B, base int, x, y Word) { var s string s = z.string(lowercaseDigits[0:base]) if t := toString(z, lowercaseDigits[0:base]); t != s { - panic(fmt.Sprintf("scanning: got %s; want %s", s, t)) + b.Fatalf("scanning: got %s; want %s", s, t) } b.StartTimer() diff --git a/libgo/go/math/sin.go b/libgo/go/math/sin.go index 2fbe3e7ec5b..ebde7d43681 100644 --- a/libgo/go/math/sin.go +++ b/libgo/go/math/sin.go @@ -98,6 +98,7 @@ var _sin = [...]float64{ 8.33333333332211858878E-3, // 0x3f8111111110f7d0 -1.66666666666666307295E-1, // 0xbfc5555555555548 } + // cos coefficients var _cos = [...]float64{ -1.13585365213876817300E-11, // 0xbda8fa49a0861a9b |