[an error occurred while processing this directive] The Computer Inside Out: Boolean Algebra [an error occurred while processing this directive]

# Boolean Algebra

The binary system allows for a new system of mathematics. In the mid-19th century, George Boole devised such a mathematical system (long before computers were created). The mathematics that he made up are now called boolean algebra. Boolean algebra is used all the time in programming, and is thus very useful to know. At the bottom of the page, we have prepared an applet to show results of boolean operations.

Boolean algebra contains 4 operations: AND, OR, XOR, and NOT.

• AND
Results in a 1 if both of the bits are 1. Else results in a 0.
A AND B is commonly expressed as AB or A*B.
Truth table:
 A B X (A AND B) 0 0 0 0 1 0 1 0 0 1 1 1
• OR
Results in a 1 if either or both of the bits are 1. Else results in a 0 (if both bits are 0).
A OR B is commonly expressed as A+B.
Truth table:
 A B X (A OR B) 0 0 0 0 1 1 1 0 1 1 1 1
• XOR (eXclusive OR)
Results in a 1 if the two bits are different, and a 0 if they are the same.
A XOR B is commonly expressed the same way as A OR B, except that the plus sign has a circle around it.
Truth table:
 A B X (A XOR B) 0 0 0 0 1 1 1 0 1 1 1 0
• NOT
This is a unary operation (like a negative sign). NOT results in the opposite of the bit.
NOT A is commonly expressed as A with a bar on top.
Truth table:
 A X (NOT A) 0 1 1 0

Although we have not presented them, there are other operations such as NOR, XNOR, and NAND. These particular ones are simply the NOT alternative of OR, XOR, and AND, respectively. The electronic sign for these is the same as what was presented above, except that there is a small circle on the tip, such as the one shown in the NOT picture.

To give you some experience about how all of these operations work, we have written a java applet which is able to execute all of the above boolean operations. However, the applet will be able to do boolean operations on multi-bit numbers. The only difference between that and what we showed you above is that above we used single digits, while with multiple digits the operation is performed on each matching pair of digits (i.e. the first bit of A with the first bit of B, and etc). Since NOT only takes one input, the first input is used when the NOT function is performed.

Note: You will need a Java 1.1 compliant browser, such as IE 4.0+, and Netscape 4.5+.

Now that you understand everything that there is to know about Boolean algebra, you can go on to the mathematics section.

[an error occurred while processing this directive]