aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2015-03-04 15:02:07 -0800
committerRobert Griesemer <gri@golang.org>2015-03-12 18:34:42 +0000
commit0ff7c3ea458dc9162333efa5ffd1ff9dccfd4fe8 (patch)
tree58bb9426b229ee92f28ecf49dbfd3234f9ae92a4
parent63269404a8d588fb0af679adc1f940294cedc2c0 (diff)
downloadgo-0ff7c3ea458dc9162333efa5ffd1ff9dccfd4fe8.tar.xz
math/big: make validate a method of Float (cleanup)
Change-Id: If38f45acffd352ed95f32f3a36edd91a1fb33d0c Reviewed-on: https://go-review.googlesource.com/6850 Reviewed-by: Alan Donovan <adonovan@google.com>
-rw-r--r--src/math/big/float.go50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/math/big/float.go b/src/math/big/float.go
index 29de05785f..60a962a6f8 100644
--- a/src/math/big/float.go
+++ b/src/math/big/float.go
@@ -188,7 +188,7 @@ func (x *Float) Acc() Accuracy {
//
func (x *Float) Sign() int {
if debugFloat {
- validate(x)
+ x.validate()
}
if len(x.mant) == 0 && x.exp != infExp {
return 0
@@ -217,7 +217,7 @@ func (x *Float) Sign() int {
// mantissa value.
func (x *Float) MantExp(mant *Float) (exp int) {
if debugFloat {
- validate(x)
+ x.validate()
}
if len(x.mant) != 0 {
exp = int(x.exp)
@@ -249,8 +249,8 @@ func (x *Float) MantExp(mant *Float) (exp int) {
// is set to exp.
func (z *Float) SetMantExp(mant *Float, exp int) *Float {
if debugFloat {
- validate(z)
- validate(mant)
+ z.validate()
+ mant.validate()
}
z.Copy(mant)
if len(z.mant) == 0 {
@@ -291,7 +291,7 @@ func (x *Float) IsNaN() bool {
// ±Inf and NaN values are not integers.
func (x *Float) IsInt() bool {
if debugFloat {
- validate(x)
+ x.validate()
}
// pick off easy cases
if x.exp <= 0 {
@@ -329,7 +329,7 @@ func (z *Float) setExp(e int64) {
}
// debugging support
-func validate(x *Float) {
+func (x *Float) validate() {
if !debugFloat {
// avoid performance bugs
panic("validate called but debugFloat is not set")
@@ -361,7 +361,7 @@ func validate(x *Float) {
// calling round.
func (z *Float) round(sbit uint) {
if debugFloat {
- validate(z)
+ z.validate()
}
z.acc = Exact
@@ -493,7 +493,7 @@ func (z *Float) round(sbit uint) {
}
if debugFloat {
- validate(z)
+ z.validate()
}
return
@@ -678,7 +678,7 @@ func (z *Float) SetNaN() *Float {
// exact (not rounded) result.
func (z *Float) Set(x *Float) *Float {
if debugFloat {
- validate(x)
+ x.validate()
}
z.acc = Exact
if z != x {
@@ -700,7 +700,7 @@ func (z *Float) Set(x *Float) *Float {
// x are the same.
func (z *Float) Copy(x *Float) *Float {
if debugFloat {
- validate(x)
+ x.validate()
}
if z != x {
z.prec = x.prec
@@ -736,7 +736,7 @@ func high64(x nat) uint64 {
// for x > math.MaxUint64, and (0, Undef) for NaNs.
func (x *Float) Uint64() (uint64, Accuracy) {
if debugFloat {
- validate(x)
+ x.validate()
}
// special cases
@@ -783,7 +783,7 @@ func (x *Float) Uint64() (uint64, Accuracy) {
// (math.MaxInt64, Below) for x > math.MaxInt64, and (0, Undef) for NaNs.
func (x *Float) Int64() (int64, Accuracy) {
if debugFloat {
- validate(x)
+ x.validate()
}
// special cases
@@ -841,7 +841,7 @@ func (x *Float) Int64() (int64, Accuracy) {
// BUG(gri) Float.Float64 doesn't handle exponent overflow.
func (x *Float) Float64() (float64, Accuracy) {
if debugFloat {
- validate(x)
+ x.validate()
}
// special cases
@@ -886,7 +886,7 @@ func (x *Float) Float64() (float64, Accuracy) {
// the result in z instead of allocating a new Int.
func (x *Float) Int(z *Int) (*Int, Accuracy) {
if debugFloat {
- validate(x)
+ x.validate()
}
if z == nil {
@@ -953,7 +953,7 @@ func (x *Float) Int(z *Int) (*Int, Accuracy) {
// the result in z instead of allocating a new Rat.
func (x *Float) Rat(z *Rat) (*Rat, Accuracy) {
if debugFloat {
- validate(x)
+ x.validate()
}
if z == nil {
@@ -1239,8 +1239,8 @@ func (x *Float) ucmp(y *Float) int {
// BUG(gri) When rounding ToNegativeInf, the sign of Float values rounded to 0 is incorrect.
func (z *Float) Add(x, y *Float) *Float {
if debugFloat {
- validate(x)
- validate(y)
+ x.validate()
+ y.validate()
}
if z.prec == 0 {
@@ -1294,8 +1294,8 @@ func (z *Float) Add(x, y *Float) *Float {
// BUG(gri) Float.Sub returns NaN if an operand is Inf.
func (z *Float) Sub(x, y *Float) *Float {
if debugFloat {
- validate(x)
- validate(y)
+ x.validate()
+ y.validate()
}
if z.prec == 0 {
@@ -1349,8 +1349,8 @@ func (z *Float) Sub(x, y *Float) *Float {
// BUG(gri) Float.Mul returns NaN if an operand is Inf.
func (z *Float) Mul(x, y *Float) *Float {
if debugFloat {
- validate(x)
- validate(y)
+ x.validate()
+ y.validate()
}
if z.prec == 0 {
@@ -1387,8 +1387,8 @@ func (z *Float) Mul(x, y *Float) *Float {
// BUG(gri) Float.Quo returns NaN if an operand is Inf.
func (z *Float) Quo(x, y *Float) *Float {
if debugFloat {
- validate(x)
- validate(y)
+ x.validate()
+ y.validate()
}
if z.prec == 0 {
@@ -1434,8 +1434,8 @@ func (z *Float) Quo(x, y *Float) *Float {
// BUG(gri) Float.Cmp does not implement comparing of NaNs.
func (x *Float) Cmp(y *Float) int {
if debugFloat {
- validate(x)
- validate(y)
+ x.validate()
+ y.validate()
}
mx := x.ord()