The bool type can hold one of only two values: true or false. This type is often used to record the result of some operation, so that you can act on this result. In particular, bool types are used to store the result of a comparison.
Four operators:
! (Logical NOT):
e.g. var1 = !var2. var1 is assigned the value true if var2 is false
&(logical AND)
e.g. var1 = var2 & var3 . var1 is assigned the value true if var2 and var3 are both true, or false otherwise.
! (Logical OR)
e.g. var = var2 | var3. var1 is assigned the value true if either var2 or var3(or both) is true, or false otherwise.
^ (exclusive OR)
e.g. var1 = var2 ^ var3 : var1 is assigned the value true if either var2 or var3, but not both, is ture or false otherwise.
Two conditional Boolean operators,
&& (also call Logical AND) ,
var1 = var2 && var3;
|| (Logical OR)
var1 = var2 || var3;
The result of these operators is exactly the same as & and |, but there is an important difference in the way this result is obtained, which can result in better performance. both of these look at the value of their first operands(var in the preceding table) and, based on the value of this operand, may not need to process the second operands (var3 in the preceding table) at all.
Four operators:
! (Logical NOT):
e.g. var1 = !var2. var1 is assigned the value true if var2 is false
&(logical AND)
e.g. var1 = var2 & var3 . var1 is assigned the value true if var2 and var3 are both true, or false otherwise.
! (Logical OR)
e.g. var = var2 | var3. var1 is assigned the value true if either var2 or var3(or both) is true, or false otherwise.
^ (exclusive OR)
e.g. var1 = var2 ^ var3 : var1 is assigned the value true if either var2 or var3, but not both, is ture or false otherwise.
Two conditional Boolean operators,
&& (also call Logical AND) ,
var1 = var2 && var3;
|| (Logical OR)
var1 = var2 || var3;
The result of these operators is exactly the same as & and |, but there is an important difference in the way this result is obtained, which can result in better performance. both of these look at the value of their first operands(var in the preceding table) and, based on the value of this operand, may not need to process the second operands (var3 in the preceding table) at all.
Comments
Post a Comment