By now you will have grasped that computers can only understand, store and manipulate two values – binary equivalents of 1 and 0. In real life, these values are held as combinations of high/ground voltage; charged/non-charged capacitors; magnetized/non-magnetized sectors on hard drive; and so on. For programming and modelling purposes, however, we think of these states as being 1 v 0 or true v false.

Today, all our computers employ a system we call Boolean Logic. Boole’s system works by taking combinations of true/false and analysing them to produce a single result, which will either be true or false. (You may already have some experience of this through searching on the Internet – “Python AND snake NOT Monty” is what is known as a Boolean Expression).
In reality, the inputs are processed by the ALU, which performs the analysis and provides the result. The ALU consists of a number of complex switching mechanisms, called Logic Gates – four basic types and three composite ones, which we will look at in turn.
|
AND gates will only yield a TRUE result (that is, a binary 1) if all input is TRUE.
Therefore, any gate with a false input (even if only one) will produce a FALSE (binary 0) result. |
|
| OR gates are
less fussy. An OR gate will send a TRUE result if any of its input is TRUE.
Only if every input is FALSE will it produce a 0 result. |
|
XOR
(Exclusive OR - sometimes called EOR) looks for differences in inputs – it is
used for comparing things. If the
inputs are all identical (no matter whether 1 or 0) it produces a 0
result. If any of them are different
from all the others, it generates a 1. |
|
|
NOT gates,
on the other hand, do just one thing. A NOT gate accepts only a single input,
either TRUE or FALSE, which it promptly reverses. |
|
The composite gates are AND, OR or XOR combined with NOT to make NAND (not and), NOR (not or) and XNOR (not XOR) gates. These new gates process input in the usual manner and then reverse the result.
|
|
|
Try this for yourself using the applet below. Choose a value for both inputs, then click on the choice box to select a gate. The output will then be displayed. (It is convention to call the inputs A, B, C etc. and the output Q. If we called the output “O” it might get confused with 0 (zero)).
Boolean logic can also be depicted as a Venn diagram. Consider the following. A “Mr Whippy” machine can dispense chocolate, vanilla or strawberry ice-cream. How many combinations can you have, and what do you ask for?
|
Strawberry OR vanilla. Actually there are three possibilities here – a pink cone, a white cone or a mixture of the two. You can have one, or the other, or both. |
|
| Strawberry AND vanilla. Only a strawberry/vanilla swirl is acceptable – strawberry on it’s own, or just plain vanilla, do not count. You need to have both. |
|
|
NOT strawberry. You could have chocolate, vanilla, or choc/vanilla combo. |
|
Strawberry XOR chocolate. This is a tough one! You must have one, or the other, but not nothing, and not both. This translates to strawberry, OR chocolate, but you can’t have a combo, or no ice cream at all. |
|
|
Chocolate AND strawberry AND vanilla. You must have a neapolitan! |
|
Boolean logic appears in many programming languages as both “boolean expressions” and a variable type in it’s own right. You declare and initialise it like this :
cone: boolean; cone := false; {pascal}
boolean cone = false; //java
dim cone as boolean; cone = false; ‘visual basic
The following examples will all use Pascal, but you’ll get the idea.
IF ((flavour = “strawberry”) OR (flavour = “chocolate”))THEN cone := true ELSE cone := false;
What the computer does here is to evaluate the expression in brackets, and decide whether or not it is true (you chose strawberry OR chocolate – it only needs one condition to be fulfilled). Then it knows what to do with “cone”.
IF ((flavour1 = “strawberry”) AND (flavour2 = “chocolate”)) THEN cone := true ELSE cone := false;
In this case, BOTH the conditions have to be true in order for “cone” to become true as well.

Later on, I will also add a page about logic circuits.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
Comments? c.nyssen@abcol.ac.uk |
Best viewed at 800x600 in 16-bit high color with Trebuchet MS installed. If you do not have this font, click here |