diff --git a/bitset.go b/bitset.go index 691c47f..cdf91c3 100644 --- a/bitset.go +++ b/bitset.go @@ -205,8 +205,8 @@ func (b *BitSet) Test(i uint) bool { return b.set[i>>log2WordSize]&(1<> log2WordSize) subWordIndex := wordsIndex(i) @@ -219,9 +219,7 @@ func (b *BitSet) Word(i uint) uint64 { // The next word, masked to only include the necessary bits and shifted to cover the // top of the word if (firstWordIndex + 1) < len(b.set) { - mask := uint64((1 << subWordIndex) - 1) - - secondWord = (b.set[firstWordIndex+1] & mask) << uint64(wordSize-subWordIndex) + secondWord = b.set[firstWordIndex+1] << uint64(wordSize-subWordIndex) } return firstWord | secondWord diff --git a/bitset_test.go b/bitset_test.go index 0dd8d24..ca21d8b 100644 --- a/bitset_test.go +++ b/bitset_test.go @@ -2079,7 +2079,7 @@ func TestWord(t *testing.T) { for name, testCase := range testCases { t.Run(name, func(t *testing.T) { bitSet := From(data) - output := bitSet.Word(testCase.index) + output := bitSet.GetWord64AtBit(testCase.index) if output != testCase.expected { t.Errorf("Word should have returned %d for input %d, but returned %d", testCase.expected, testCase.index, output)