& Is a logical operator, & Is a bitwise Operator
& | You can perform logical operations or bit operations,
&, | The two sides can only be bool type
&, | The two sides can be bool type or numeric type
Differences:
If (A & B) if A is false, the entire expression is false and the value of B is no longer calculated.
If (A & B) if A is false, the entire expression is false, but the value of B must be calculated.
If (A & B ++)If a is false
If (A & B ++) if A is false, & the following value is calculated.
(&) Pre-defines two operation rules for integer and bool types.For integer, & Calculates the bitwise "and" of the operands ";Bool operations, & Calculates the logic of the operand "and ";
That is to say, the bool type and the IF judgment result of & are the same.
For Integer Data & only true and false (0 or not), data on both sidesAll must be trueOrEither party is false;
Perform bitwise AND operation on the integer data and the data on both sides, and return the calculation result so that if can judge the value.
Logic (and): True & false: false
By-bit (and): 1001 0110 & 1111 1111: 1001 0110 (Binary)