if m == 0 {
// 0.0 or Inf
if x.exp != 0 && x.exp != infExp {
- panic(fmt.Sprintf("%empty matissa with invalid exponent %d", x.exp))
+ panic(fmt.Sprintf("empty matissa with invalid exponent %d", x.exp))
}
return
}
return z, acc
}
-// Rat returns the result of converting x into a quotient;
+// Rat returns the rational number corresponding to x;
// or nil if x is an infinity.
// If a non-nil *Rat argument z is provided, Rat stores
// the result in z instead of allocating a new Rat.
}
}
-var bitsTests = []nat{
- nil,
- {0},
- {1},
- {0, 1, 2, 3, 4},
- {4, 3, 2, 1, 0},
- {4, 3, 2, 1, 0, 0, 0, 0},
-}
-
func norm(x nat) nat {
i := len(x)
for i > 0 && x[i-1] == 0 {
}
func TestBits(t *testing.T) {
- for _, test := range bitsTests {
+ for _, test := range []nat{
+ nil,
+ {0},
+ {1},
+ {0, 1, 2, 3, 4},
+ {4, 3, 2, 1, 0},
+ {4, 3, 2, 1, 0, 0, 0, 0},
+ } {
var z Int
z.neg = true
got := z.SetBits(test)
}
if got.neg {
- t.Errorf("SetBits(%v): got negative result")
+ t.Errorf("SetBits(%v): got negative result", test)
}
bits := nat(z.Bits())