Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 1.04 KB

three-basic-bitwise-operations.md

File metadata and controls

27 lines (21 loc) · 1.04 KB

三种基本的位运算 (Three basic bitwise operations)

  1. Bitwise AND operator (&) returns a new number by performing a logical AND operation on each corresponding pair of bits in the two input numbers. (位与运算符(&)通过对两个输入数字中的每一对相应位执行逻辑与操作,返回一个新的数字。)
// 1 & 1 = 1
// 1 & 0 = 0
// 0 & 1 = 0
// 0 & 0 = 0
  1. Bitwise OR operator (|) returns a new number by performing a logical OR operation on each corresponding pair of bits in the two input numbers. (位或运算符(|)通过对两个输入数字中的每一对相应位执行逻辑或操作,返回一个新的数字。)
// 1 | 1 = 1
// 1 | 0 = 1
// 0 | 1 = 1
  1. Bitwise XOR operator (^) returns a new number by performing a logical XOR operation on each corresponding pair of bits in the two input numbers. (位异或运算符(^)通过对两个输入数字中的每一对相应位执行逻辑异或操作,返回一个新的数字。)
// 1 ^ 1 = 0
// 1 ^ 0 = 1
// 0 ^ 1 = 1
// 0 ^ 0 = 0