First, it is good to review the concepts of the truth table, to understand how to input and boolean values work.
A truth table is nothing more than a logic machine that for a given input or value and its output is calculated according to logical, functional, and Boolean predeterminations
Logical operators are nothing less than mathematical functions and expressions, yes the ones you probably studied in school.
- The logical operator AND also called logical conjunction, is used for given two value inputs where it produces a true value if both operands are true. In programming logic, there are two values in bits that represent true or false which are: 1 and 0
- Logical OR operator also called Logical Disjunction, given two inputs with values, it produces a true value if at least one of its operands is true.
The logical operator XOR represents the inequality function that is if both inputs are true or false the output will be false (0) if both inputs differ it will return true. A nice phrase to remember the logic of XOR is :
"must have one or the other, but not both "
The analytical presentation of this logical operator is given by the expression:
- An interesting curiosity that you may not have realized yet is that the logical operator XOR is the conversion of the AND and OR operators, and so when you have a logical AND and want to turn it into a logical OR you will use the XOR.
- After a summary of logical operators and truth table we can now get back to solving the problem that triggered this post.
Simple, since we do not have a real symbol for this operator we can represent it with the conversion of the AND to OR operators that would look like this:
bCondition1 && bCondition2
!(!bCondition1 || !bCondition2)
I hope this post has helped you or added something to it \o/