From 31e852402fdf36ccc9fd84436d082e960b755cd3 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 13 Feb 2015 12:47:44 -0800 Subject: math/big: fix aliasing error in Add, Sub Also: - make representation more flexible (no need to store trailing 0 digits to match precision) - simplify rounding as a consequence - minor related fixes TBR adonovan Change-Id: Ie91075990688b506d28371ec3b633b8267397ebb Reviewed-on: https://go-review.googlesource.com/4841 Reviewed-by: Rob Pike --- src/math/big/float_test.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/math/big/float_test.go') diff --git a/src/math/big/float_test.go b/src/math/big/float_test.go index 2f804fa569..be2ac6ff06 100644 --- a/src/math/big/float_test.go +++ b/src/math/big/float_test.go @@ -729,14 +729,20 @@ func TestFloatNeg(t *testing.T) { } func TestFloatInc(t *testing.T) { - var x, one Float - // x.prec = 256 TODO(gri) This doesn't work at the moment - one.SetInt64(1) - for i := 0; i < 10; i++ { - x.Add(&x, &one) - } - if s := x.Format('g', 10); s != "10" { - t.Errorf("got %s; want 10", s) + const n = 10 + for _, prec := range precList { + if 1<