15.22
Conditional And Operator
&&
EXPRESSIONS
For
^
, the result value is
true
if the operand values are different; otherwise,
the result is
false
.
For
|
, the result value is
false
if both operand values are
false
; otherwise,
the result is
true
.
15.22 Conditional And Operator
&&
The
&&
operator is like
&
( 15.21.2), but evaluates its right hand operand only if
the value of its left hand operand is
true
. It is syntactically left associative (it
groups left to right). It is fully associative with respect to both side effects and
result value; that is, for any expressions
a
,
b
, and
c
, evaluation of the expression
((a)&&(b))&&(c)
produces the same result, with the same side effects occur
ring in the same order, as evaluation of the expression
(a)&&((b)&&(c))
.
ConditionalAndExpression:
InclusiveOrExpression
ConditionalAndExpression
&&
InclusiveOrExpression
Each operand of
&&
must be of type
boolean
, or a compile time error occurs.
The type of a conditional and expression is always
boolean
.
At run time, the left hand operand expression is evaluated first; if its value is
false
, the value of the conditional and expression is
false
and the right hand
operand expression is not evaluated. If the value of the left hand operand is
true
,
then the right hand expression is evaluated and its value becomes the value of the
conditional and expression. Thus,
&&
computes the same result as
&
on
boolean
operands. It differs only in that the right hand operand expression is evaluated
conditionally rather than always.
15.23 Conditional Or Operator
||
The
||
operator is like
|
( 15.21.2), but evaluates its right hand operand only if
the value of its left hand operand is
false
. It is syntactically left associative (it
groups left to right). It is fully associative with respect to both side effects and
result value; that is, for any expressions
a
,
b
, and
c
, evaluation of the expression
((a)||(b))||(c)
produces the same result, with the same side effects occur
ring in the same order, as evaluation of the expression
(a)||((b)||(c))
.
ConditionalOrExpression:
ConditionalAndExpression
ConditionalOrExpression
||
ConditionalAndExpression
366
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved