86
This expression...
... resolves to this value.
(3==3)&&(4==4)
1
1&&(4==5)
0
0&&(4==4)
0
(3==6)&&0
0
Logical-Or (||) Operator
Assume you have two Boolean expressions,
Expression1
and
Expression2
, each returning true
(
1
) or false (
0
). The logical-or operator determines the true or false state of the complex expression
Expression1||Expression2
using the rules applying to a traditional logical OR statement:
If
Expression1
is...
and
Expression2
is...
Expression1&&Expression2
resolves to...
True (1)
True (1)
True (1)
True (1)
False (0)
True (1)
False (0)
True (1)
True (1)
False (0)
False (0)
False (0)
In other words:
This expression...
... resolves to this value.
(3==3)||(4==4)
1
1||(4==5)
1
0||(4==4)
1
(3==5)||0
0
Logical-Not (!) Operator
The logical-not is a prefix operator that “negates” the Boolean expression that follows it. In other words,
if
Expression1
returns true (
1
),
!Expression1
returns false (
0
).
For example:
This expression...
... resolves to this value.
!0
1
!(4==3)
1