python operator ^ | ~ >> <<

(&

# 5 & 6 , 5, and 6 is converted to binary 101 and 110, case 101 & 110 = 100 , 100 are converted to decimal 4, the 5 & 6 = 4

(|

# 5 | 6 is 101 | 110 , to give 111 = 7 (^) # 5 ^ 6 , is 101 ^ 110 , to give 011 = 3

(~)

# ~ . 5 . 5 is 101, inverted by 010 = 2

(>>)

# 10 >> 2 is 10  @ 2 to give 2 ** 2 
# for a right shift operation, the result is NUM @ 2 ** COUNT, i.e., the current value is divided by 2 ^ n rounding

(<<)

# 10 << 2 is 10 * 2 ** 2 to give 40 
# for the left shift operation, the result is NUM * 2 ** COUNT, i.e., the current value is multiplied by 2 to the power of n

Guess you like

Origin www.cnblogs.com/xiaoqianbook/p/11238141.html
Recommended