A computer, of course, needs to do operations with its bits, in order to achieve the results we expect ...
The operations with the bits are called BOOLEAN ALGEBRA (from the name of its creator: George BOOLE [1815-1864] one with two BRONZE ATTRIBUTES, let me tell you ...)
Let's start with the first operation: NEGATION (NOT)
It simply inverts the value of the bit: hence NOT 1 = 0 and NOT 0 = 1
If you think about it is simple enough: if it is not 1 .... it can not be anything else that 0 ... isn't it?
To define a Boolean operation, the TRUTH TABLE is used, that is a simple table in which the results of the operation are put, which is simple to do, as there are only 4 possible combinations ...
Since we have talked about truth, it is good to specify that 1 = TRUE and 0 = FALSE
Now let's see the OR (like in grammar "OR"):
The OR operation is TRUE if AT LEAST ONE of the terms is TRUE, if you prefer you can also say that the OR operation is 1 if at least one of the terms is 1
The truth table is now simple to define ...
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1
In a very similar way we have operation AND (grammar "AND", in the sense of conjunction)
The AND operation is TRUE if ALL the terms are TRUE, if you prefer you can also say that the AND operation is equal to 1 if ALL the terms are 1
The truth table is still very simple:
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
The parentheses are also valid in Boolean algebra, indicating that the operation contained in them must be done first, otherwise the order in which the operations are performed is 1 °) NOT, 2 °) AND, 3 °) OR
A small example:
1 AND 0 OR 1 AND 1 OR 0
first you make the AND, so it comes:
0 OR 1 OR 0 = 1
If instead I had written
(1 AND 0) OR 1 AND (1 OR 0)
First I should do the brackets, then:
0 OR 1 AND 0
Then the AND ...
0 OR 0 = 0