Newbie question. How to calculate the value of the formula A f B, where f - the binary function OR or AND?
Logical OR is ||
, logical AND is &&
.
If you need the negation NOT, prefix your expression with !
.
Example:
X = (A && B) || C || !D;
Then X will be true when either A and B are true or if C is true or if D is not true (i.e. false).
If you wanted bit-wise AND/OR/NOT, you would use &
, |
and ~
. But if you are dealing with boolean/truth values, you do not want to use those. They do not provide short-circuit evaluation for example due to the way a bitwise operation works.