diff options
Diffstat (limited to 'libgo/go/big/rat.go')
-rw-r--r-- | libgo/go/big/rat.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libgo/go/big/rat.go b/libgo/go/big/rat.go index 327b9bd..f435e63 100644 --- a/libgo/go/big/rat.go +++ b/libgo/go/big/rat.go @@ -27,9 +27,13 @@ func NewRat(a, b int64) *Rat { // SetFrac sets z to a/b and returns z. func (z *Rat) SetFrac(a, b *Int) *Rat { - z.a.Set(a) z.a.neg = a.neg != b.neg - z.b = z.b.set(b.abs) + babs := b.abs + if &z.a == b || alias(z.a.abs, babs) { + babs = nat(nil).set(babs) // make a copy + } + z.a.abs = z.a.abs.set(a.abs) + z.b = z.b.set(babs) return z.norm() } |