PHP's Bitwise Operators What does it mean

Bitwise Operators What does it mean?

Bitwise operators (Bitwise Operators) is an operator for performing digital binary bit pattern or bit operations involving a single bit operation.

The bitwise operators may be used:

1, a communication stack, wherein the header bits to the respective data representing critical information

2, embedded software, for controlling the different functions of the chip, and to indicate the status of each hardware manipulating hardware registers bit embedded microcontroller

3, such as a low-level programming for the device driver, encryption software, video decoder software, memory allocator, compression software and graphics applications

4, in the search and optimization problems effectively maintain a large integer

5, to perform bitwise flag, which can make any combination of the values ​​stored in a list of instances enumerated type defined enumerator

PHP's Bitwise Operators What?

Used in PHP bitwise operators are:

1, & (bitwise AND)

Only when both operands are true, the only result of the expression is true. It can be used to check the set values ​​of some masking bit.

2, | (bitwise OR)

When any of a number (-s) of the operation is true, the result of the expression is true.

3, ^ (bitwise exclusive or)

If and only if one of the operands is true, the result was the expression is true. It is mainly used to switch some of the bits; it also helps to exchange variables rather than two third variable.

4, ~ (bitwise NOT)

By inverting the value of the operand to provide the bitwise complement, such that all zeros are changed to 1 and 1 are all zero.

5, >> (bitwise right shift) and << (bitwise left shift)

The number of bits right or left second operand specified location. Int is the arithmetic right shift operation or operand type long displacement, and for uint or ulong operand type, it is logical shift. Bit shift operator to align.

PHP order bitwise operators

Order of precedence bit operators (from highest to lowest) is:

1、~

2、<<和>>

3、&

4、^

5、|

 

Reference: http://www.php.cn/php-weizijiaocheng-414117.html

Guess you like

Origin www.cnblogs.com/andydao/p/11019446.html