A different way of thinking
It is important to appreciate that Boolean numbers are subject to a different system of mathematics from ‘regular’ numbers. Furthermore, Boolean numbers should not be confused with binary, which is simply an alternative notation for regular denary numbers. Boolean quantities are restricted to 1 or 0 only (all or nothing), whereas a binary number may be composed of several bits representing any finite value. From a Boolean perspective, the binary number 101011 (denary 43) does not exist!
Consider the following simple addition sums.
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 1
The first three of these present no surprises, but the last one looks strange. When it comes to Boolean algebra, there are only two possible values, 1 or 0. There is no such thing as 2. Since the result of 1+1 is undoubtedly not zero, it must therefore be 1. In fact 1 +1 + 1 + 1 + 1 = 1.
Notice the similarity between these sums and the truth table for an OR gate.
Boolean addition corresponds to the logical function of an OR gate.
Input 1 | Input 2 | Output |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Consider the following simple multiplication sums.
0 * 0 = 0
0 * 1 = 0
1 * 0 = 0
1 * 1 = 1
There are no surprises here at all. Boolean multiplication works as you might expect (anything multiplied by 0 is 0).
Notice the similarity between these sums and the truth table for an AND gate.
Boolean multiplication corresponds to the logical function of an AND gate.
Input 1 | Input 2 | Output |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
There is no such thing as Boolean subtraction which would imply the existence of negative numbers; there is only 1 and 0. There is no such thing as division either, because division is actually repeated subtraction.
Order of precedence
When writing arithmetic expressions there is an order in which arithmetic operations should be performed. In denary for example, 12 / 4 + 2 equates to 5, not 2. Most children learn the acronym BODMAS (brackets of division, multiplication, addition, subtraction), which specifies that division has a higher precedence than addition. On the other hand 12 / (4 + 2) equates to 2, because the brackets have an even higher precedence.
There is also an order of precedence for Boolean operations; NOT then AND then OR. Brackets can be used to specify that certain operations are performed first. Hence the expression P = ¬(AvB) does not mean the same thing when written without brackets P = ¬AvB. However the expression P = ¬Cv(A^B) is equivalent to P = ¬CvA^B.