Home >Backend Development >C#.Net Tutorial >What is & called in C language?
The & operator in C language is called the bitwise AND operator and the logical AND operator. The bitwise AND operator (&) performs an AND operation on each bit of the operand, and the result is 1 only if both bits are 1. The logical AND operator (&&) performs a logical operation and the result is true only if both operands are true.
& operator’s name in C language
& operator’s name in C language is Bitwise AND operator or Logical AND operator.
Bitwise AND Operator
The bitwise AND operator (&) performs a bitwise operation, that is, a union operation is performed on each bit of the two operands. The resulting bit is 1 only if both bits are 1, otherwise it is 0. For example:
3 & 5 = 1 (二进制:11 & 101 = 01)
Logical AND operator
The logical AND operator (&&) performs a logical operation, that is, a logical AND operation on two Boolean operands. The result is true only if both operands are true, otherwise it is false. For example:
(3 != 0) && (5 > 2) = true
When you need to distinguish the logical AND operator from the bitwise AND operator, it is more explicit to use the logical AND operator (&&). Generally speaking, use & when performing bitwise operations and && when performing logical operations.
The above is the detailed content of What is & called in C language?. For more information, please follow other related articles on the PHP Chinese website!