What the heck is a bitwise AND

advertisement
What the heck is a bitwise AND?
To answer the query Brutus AND Caesar AND NOT Calpurnia, we take the vectors for
Brutus, Caesar and Calpurnia, complement the last, and then do a bitwise AND:
110100 AND 110111 AND 101111 = 100100
Answer:
This is computer talk and makes things very simple if you are a geek. For humans:
Take each of the three names and just copy the row of zeros and ones without any spaces:
Brutus
110100
Caesar
110111
Calpurnia
010000
Note: we can think of 1 as meaning true and 0 as meaning false so the first 1 For Brutus
means: It is true that name Brutus appears in the play “Anthony and Cleopatra”
But the query says NOT Calpurnia
To do a complement we just change all the 0’s to 1’s and all the 1’s to 0’s so Calpurnia
becomes
101111
Now the first 1 for Calpurnia means: It is not true that Calpurnia appears in the play
“Anthony and Cleopatra”
Now to do the bitwise and, we line up all three sets and apply the following rule to each
column: If both the values in the column are 1 then the result is 1, otherwise the result is
0
Brutus
110100 AND
Caesar
110111
Result
Not Calpurnia
110100 AND
101111
Result
100100
And going back to the matrix the 1’s identify the first and fourth plays.
Avoid confusion – This deals with how to do a geek complement, If you want to
compliment a geek try something like: “You don’t smell so bad for a computer
programmer.”
The Intersect if your brain contains neurons rather than wires;
Section 1.3 gives the steps for doing an intersect – which is to say a Boolean AND
1. Find a place where you are going to write down the answer
2. As long as you haven’t looked at all the numbers in either the Brutus list or the
Calpurnia list, keep on going. Otherwise quit.
3. Start with the first document number in each list
3a Compare the document numbers from each list
4 If the document numbers match, write the document number to you answer
5 If the document numbers match, move up to the next number in the Brutus list
6 If the document numbers match, move up to the next number in the Calpurnia list
7 If the document numbers do not match compare the two document numbers
8 If the document numbers do not match and the document number in the Brutus
list is smaller, move up to the next number in the Brutus list and keep the same
document number from the Calpurnia list.
9 If the document numbers do not match and the document number in the
Calpurnia list is smaller, move up to the next number in the Calpurnia list and
keep the same document number from the Brutus list
10 Now go back to step 2 and if it is not time to quit then skip step 3 and go on with
step 3a
Now – try it yourself. Follow the steps and see if your answers are 2 and 31
You can ignore most of the rest of this section since it only makes the point that, for a
geek, it is real simple to get a computer to do a Boolean search – even a complicated one.
This partly explains why almost every retrieval system can handle Boolean searches.
Download