Logical AND logical OR logical is not a Boolean worthwhile operation, it belongs to the discrete mathematics category.
bitwise AND, bitwise OR, bitwise is not the operation of the computer bit, belongs to the computer bits operation category.
Logic and all true is true C in the distinction between &, &&.
Logical OR TRUE is true C in the distinction between |, | | The difference.
Logic is not fake to really C in!.
bitwise AND, bitwise, or bitwise non-follow the above rules for each of the logical operations, where 1 represents true 0 for false.
One is a bitwise operation, one is a conditional calculation operation
The logical operator is used to determine the true and false; bit operators are used.
& C + + and && | with | | the difference:
&&
Denotes the meaning of logic and, that is, and . When the result of an expression on either side of the operator is true, the result of the entire operation is true, otherwise, theresult is false, as long as there is a side of false .
For example , the result of 12&&23 is 1,12&&-1 The result is 1,123&&0 The result is 0 .
&& also has a short-circuit function, that is, if the first expression is false, the second expression is no longer evaluated, for example, for if (str! = null &&!str.equals ("")) expression, when str is null , subsequent expressions do not execute, so the nullpointerexception is not present .
&
Represents a bitwise-to.
& represents bitwise AND operation, we typically use 0x0f to perform a & operation with an integer to get the minimum 4 bit bits of the integer , for example,0x31 & The result of 0x0f is 0x01.
Binary and Operation rules : 1&1=1 1&0=0 0&0=0
Why is 15&127 equal to the ah?
Binary : (0000 1111)
127 binary : (1111 1111)
Bitwise AND Nature is (0000 1111) =
||
Represents a logical OR
Logical OR, is a logical operator, the symbol is "| |" ( "or" in PASCAL). "Logical OR" is equivalent to the "or" in life, when any one of the two conditions satisfies, the" logical OR " result of the operation is " true "
12| | 1 = 1 12| | 0 = 1 0| | 0 =0
|
Represents a bitwise OR
bitwise OR operation bitwise OR operator ' | ' is the binocular operator. Its function is to participate in the operation of the two number of the corresponding binary (i.e. the last one) phase or. As long as the corresponding two binary has one of 1 , the result bit is 1.
£ º (0001 0000 0000)
127: (0000 1111 1111) (high 0 )
Bitwise OR IS (0001 1111 1111) =255
Logical AND, bitwise VS; logical OR, bitwise or between the differences