Simplify bitMask calculation.

This commit is contained in:
Nigel Tao committed 2017-05-28 18:51:54 +10:00
1 parent 843e35aff5
commit ef55631cbd
2 files changed
+9 -12

No files matched your search

+2 -2
View File
@@ -225,7 +225,7 @@ func TestConstValues(t *testing.T) {
}
}
func TestRoundUpToPowerOf2Minus1(t *testing.T) {
func TestBitMask(t *testing.T) {
testCases := [][2]uint64{
{0, 0},
{1, 1},
@@ -255,7 +255,7 @@ func TestRoundUpToPowerOf2Minus1(t *testing.T) {
}
for _, tc := range testCases {
got := roundUpToPowerOf2Minus1(big.NewInt(0).SetUint64(tc[0]))
got := bitMask(big.NewInt(0).SetUint64(tc[0]).BitLen())
want := big.NewInt(0).SetUint64(tc[1])
if got.Cmp(want) != 0 {
t.Errorf("roundUpToPowerOf2Minus1(%v): got %v, want %v", tc[0], got, tc[1])