Commit 04ce9dbf authored by Robert Griesemer's avatar Robert Griesemer

math/big: correct umax

Change-Id: I208c8ac44d1a8882d8fdeb18347dc20941e20374
Reviewed-on: https://go-review.googlesource.com/4250Reviewed-by: default avatarAlan Donovan <adonovan@google.com>
parent f8176f81
...@@ -439,7 +439,7 @@ func (z *Float) SetInt64(x int64) *Float { ...@@ -439,7 +439,7 @@ func (z *Float) SetInt64(x int64) *Float {
return z return z
} }
// SetInt64 sets z to the (possibly rounded) value of x and returns z. // SetFloat64 sets z to the (possibly rounded) value of x and returns z.
// If z's precision is 0, it is changed to 53 (and rounding will have // If z's precision is 0, it is changed to 53 (and rounding will have
// no effect). // no effect).
// If x is denormalized or NaN, the result is unspecified. // If x is denormalized or NaN, the result is unspecified.
...@@ -525,8 +525,7 @@ func (z *Float) SetRat(x *Rat) *Float { ...@@ -525,8 +525,7 @@ func (z *Float) SetRat(x *Rat) *Float {
a.SetInt(x.Num()) a.SetInt(x.Num())
b.SetInt(x.Denom()) b.SetInt(x.Denom())
if z.prec == 0 { if z.prec == 0 {
// TODO(gri) think about a.prec type to avoid excessive conversions z.prec = umax(a.prec, b.prec)
z.prec = uint(max(int(a.prec), int(b.prec)))
} }
return z.Quo(&a, &b) return z.Quo(&a, &b)
} }
...@@ -1072,7 +1071,7 @@ func (x *Float) Sign() int { ...@@ -1072,7 +1071,7 @@ func (x *Float) Sign() int {
} }
func umax(x, y uint) uint { func umax(x, y uint) uint {
if x < y { if x > y {
return x return x
} }
return y return y
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment