return x.abs.bitLen()
}
+// TrailingZeroBits returns the number of consecutive least significant zero
+// bits of |x|.
+func (x *Int) TrailingZeroBits() uint {
+ return x.abs.trailingZeroBits()
+}
+
// Exp sets z = x**y mod |m| (i.e. the sign of m is ignored), and returns z.
// If m == nil or m == 0, z = x**y unless y <= 0 then z = 1.
//
}
}
+var tzbTests = []struct {
+ in string
+ out uint
+}{
+ {"0", 0},
+ {"1", 0},
+ {"-1", 0},
+ {"4", 2},
+ {"-8", 3},
+ {"0x4000000000000000000", 74},
+ {"-0x8000000000000000000", 75},
+}
+
+func TestTrailingZeroBits(t *testing.T) {
+ for i, test := range tzbTests {
+ in, _ := new(Int).SetString(test.in, 0)
+ want := test.out
+ got := in.TrailingZeroBits()
+
+ if got != want {
+ t.Errorf("#%d: got %v want %v", i, got, want)
+ }
+ }
+}
+
func BenchmarkBitset(b *testing.B) {
z := new(Int)
z.SetBit(z, 512, 1)