📜  bitshift - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:34.609000             🧑  作者: Mango

代码示例2
int i = 7;    // Decimal 7 is Binary (2^2) + (2^1) + (2^0) = 0000 0111
int j = 3;    // Decimal 3 is Binary         (2^1) + (2^0) = 0000 0011
k = (i << j); // Left shift operation multiplies the value by 2 to the power of j in decimal
              // Equivalent to adding j zeros to the binary representation of i
              // 56 = 7 * 2^3
              // 0011 1000 = 0000 0111 << 0000 0011