To learn what makes a computer tick, start by learning the basics of digital logic and the components that execute that logic. Even the most complex digital circuits can be built with just a few basic building blocks.
Binary arithmetic is fundamental to understanding digital electronics. It's not possible with current technology to break an electronic signal into 10 distinct levels to represent the digits 0 through 9. Binary arithmetic requires only two signal levels, so it is used instead. Think of an "off" or "low" signal as representing a 0, and an "on" or "high" signal as representing a 1.
To understand binary arithmetic, recall how the decimal system works. The digits 0 through 9 are written in columns that indicate whether they are to be multiplied by 1, 10, or 100, etc., to derive the correct number; e.g., 357 = 3x100 + 5x10 + 7x1. The binary system is similar, except the columns indicate whether the digits 0 or 1 are to be multiplied by 1, 2, 4, 8, 16 and so on. For example, the number 1011 in the binary system is 1x1 + 1x2 + 0x4 + 1x8 = 13.
Addition, subtraction, multiplication and division are the same as in decimal arithmetic. In the binary system, 1+1 = 10 and the 1 is carried similar to the one in the decimal system for 9+1=10.
The three basic digital operations include NOT, AND, and OR.
NOT is the complement (opposite) of the input value X. It is written as --X, X' or sometimes with a bar over the top.
X = 1, X' = 0
AND is a one or high value only if both inputs are ones or high values; it is a zero otherwise. AND is also written as X.
X = 1, Y = 1, X X Y = 1;
X = 0, Y = 1, X X Y = 0;
OR is a zero or low value only if both inputs are zeros or low values; it is a one otherwise. OR is also written as +.
X = 1, Y = 0, X + Y = 1;
X = 0, Y = 0, X + Y = 0;
Three other common binary operations include NAND, NOR and XOR.
For NAND and NOR, the complement of AND or OR is taken after the function is performed. XOR is one if both input values have the same state and zero otherwise. So, 1 XOR 1 and 0 XOR 0 are both 0, but 0 XOR 1 and 1 XOR 0 are both 1.
X = 1, Y = 1, X NAND Y = 0, X XOR Y = 0;
X = 0, Y = 0, X NAND Y = 1, X XOR Y = 0