AND logic corresponds tomultiplication.
Anything multiplied by 0 is 0, and anything multiplied by 1 remains unchanged.
If I multiply A times B, it’s possible for you to see how this works.
To get a result of 1, both A and B must be 1.
All other combinations return zero.
To check this result, I can use theAND functionto evaluate A and B.
AND returns either TRUE or FALSE.
To get a 1 or 0, I can use a double negative.
you’re able to see results are now exactly the same.
Now let’s look at OR logic.
OR logic corresponds toaddition.
0 + 0 = 0.
0 + 1 and 1 + 0 = 1.
Finally, 1 + 1 also equals 1.
This last result may be confusing, but remember that boolean algebra only allows 1s and 0s.
To demonstrate how this works, I’ll start with theOR function.
When I evaluate A and B with OR, we get a TRUE or FALSE.
Again, I’ll use a double negative to force the result to 1 or 0.
If either A and B are 1, then the result is 1.
Only when both A and B are 0 is the result zero.
Now let’s generate the same result with addition.
This reminds us that although we are simulating Boolean algebra, Excel is not automatically enforcing a boolean result.
We need to handle that ourselves in the formula.
In this case, a simple solution is to verify if the result is greater than zero.
This will give us a TRUE or FALSE.
And again, I’ll use a double negative to get a 1 or 0.