Computer processors don't necessarily support
every arithmetic operation. Some support just
ADD and SUB. But every
processor supports the logical operations:
AND OR NOT XOR
These operations are essential for data processing.
They operate on values True and
False. You can imagine the link to binary
numbers. True is \( 1 \) and
Fales is \( 0 \).
In the 1850s, English mathematician George Boole expressed the process of logical deduction in mathematical form. We now know that study as Boolean algebra, and celebrate his wonderful name every day in the boolean values we use when computing.
The logical operations have names so intuitive that
they barely need explanation.
\( x \wedge y \) is True only if both
\( x \) and \( y \) are True.
AND is usually
denoted by the symbol ∧.
Its table is the same as multiplication table.
∧| 0 1 ---+------- 0| 0 0 1| 0 1
AND applied to two bytes is applied bit by bit.
Here is the AND of two bytes. In many cases,
we aren't interested in the numerical values.
Instead, the bytes represent some other form
of data.
01100100 ∧ 00111101 ------------ 00100100
A numerical application of AND is testing whether a
byte value is even or odd.
01100100 decmal 100 ∧ 00000001 ------------ 00000000 1 if odd, 0 if even