Hello gri (cc: golang-dev@googlegroups.com), I'd like you to review this change.
LGTM thanks. - gri On Mon, Nov 29, 2010 at 3:02 PM, <ejsherry@gmail.com> wrote: > Reviewers: gri, > > Message: > Hello gri (cc: golang-dev@googlegroups.com), > > I'd like you to review this change. > > > Description: > big: fix (*Rat) SetFrac64(a, b) when b < 0. > > Please review this at http://codereview.appspot.com/3352041/ > > Affected files: > M src/pkg/big/rat.go > M src/pkg/big/rat_test.go > > > Index: src/pkg/big/rat.go > =================================================================== > --- a/src/pkg/big/rat.go > +++ b/src/pkg/big/rat.go > @@ -35,9 +35,8 @@ > func (z *Rat) SetFrac64(a, b int64) *Rat { > z.a.SetInt64(a) > if b < 0 { > - z.b.setUint64(uint64(-b)) > + b = -b > z.a.neg = !z.a.neg > - return z.norm() > } > z.b = z.b.setUint64(uint64(b)) > return z.norm() > Index: src/pkg/big/rat_test.go > =================================================================== > --- a/src/pkg/big/rat_test.go > +++ b/src/pkg/big/rat_test.go > @@ -257,3 +257,26 @@ > t.Errorf("got %s want %s", z, q) > } > } > + > + > +var setFrac64Tests = []struct { > + a, b int64 > + out string > +}{ > + {0, 1, "0"}, > + {0, -1, "0"}, > + {1, 1, "1"}, > + {-1, 1, "-1"}, > + {1, -1, "-1"}, > + {-1, -1, "1"}, > + {-9223372036854775808, -9223372036854775808, "1"}, > +} > + > +func TestRatSetFrac64Rat(t *testing.T) { > + for i, test := range setFrac64Tests { > + x := new(Rat).SetFrac64(test.a, test.b) > + if x.RatString() != test.out { > + t.Errorf("#%d got %s want %s", i, x.RatString(), > test.out) > + } > + } > +} > > >
*** Submitted as http://code.google.com/p/go/source/detail?r=90a6dee6537e *** big: fix (*Rat) SetFrac64(a, b) when b < 0. R=gri CC=golang-dev http://codereview.appspot.com/3352041 Committer: Robert Griesemer <gri@golang.org>