Bitwise Operators in PHP

Bitwise operators allow integer bits specified operation and evaluated.

Example Name Result

  1. $ A & $ b And (bitwise AND) in $ a $ b are the bits that are set.
  2. $ A | $ b Or (bit-or) will be $ a and $ b in any one of 1 bit is set to 1.
  3. $ A ^ $ b Xor (bitwise XOR) will be $ a $ b and the other one is a 0 bit is set to 1.
  4. ~ $ A Not (bitwise) the bit 0 is set to 1 $ a, and vice versa.
  5. $ A << $ b Shift left (left) of the $ a $ b times a bit to the left (each step means "multiply by 2").
  6. $ A >> $ b Shift right (right) in the $ a $ b times a bit to the right (each step means "divide by 2").

Displacement is the math in PHP. Shift in any direction out bits are discarded. When left to the right of the zero padding, the sign bit has been removed means that the sign is not retained. When the left to the right sign bit stuffing means it is retained sign.

Guess you like

Origin www.cnblogs.com/jiaoran/p/12539616.html
Recommended