math/big: replace Float.NewInf with Float.SetInf for more consistent API

Change-Id: I2a60ea4a196eef1af5d2aae6cc239c64bddb6fb2
Reviewed-on: https://go-review.googlesource.com/6301
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2015-02-25 15:38:15 -08:00
parent 612dd6c262
commit c3dc78f301
2 changed files with 35 additions and 9 deletions

View file

@ -82,12 +82,6 @@ const (
MaxPrec = math.MaxUint32 // largest (theoretically) supported precision; likely memory-limited
)
// NewInf returns a new infinite Float value with value +Inf (sign >= 0),
// or -Inf (sign < 0).
func NewInf(sign int) *Float {
return &Float{neg: sign < 0, exp: infExp}
}
// Accuracy describes the rounding error produced by the most recent
// operation that generated a Float value, relative to the exact value:
//
@ -633,6 +627,17 @@ func (z *Float) SetRat(x *Rat) *Float {
return z.Quo(&a, &b)
}
// SetInf sets z to the infinite Float +Inf for sign >= 0,
// or -Inf for sign < 0, and returns z. The precision of
// z is unchanged and the result is always Exact.
func (z *Float) SetInf(sign int) *Float {
z.acc = Exact
z.neg = sign < 0
z.mant = z.mant[:0]
z.exp = infExp
return z
}
// Set sets z to the (possibly rounded) value of x and returns z.
// If z's precision is 0, it is changed to the precision of x
// before setting z (and rounding will have no effect).