轮班操作在条件下使用的说明

Explanation of shift operationals use in condition

本文关键字:说明 条件下 操作      更新时间:2023-10-16

我有一个c代码给我填写我的论文。您能否解释一下以下部分的作用,因为我对此非常满意。

int i;
_int8 codeword[64800];
//loop running through codeword
if (codeword[i << 1] << 1 | codeword[i << 1 | 1])
{
//more code here
}

其中 i 是一个循环计数器和 码字[]是一个由一和零组成的一维矩阵

我主要寻求对发生的操作的解释,例如,如果代码字[i]为1。

该测试将偏移量2 * i2 * i + 1的 2 位codeword组合在一起,如果它们不是两个0,则评估主体。 表达式解析为:

int i;
_int8 codeword[64800];
//loop running through codeword
if ((codeword[i << 1] << 1) | codeword[(i << 1) | 1]) {
// more code here
}

请注意,该表达式将等效,但更具可读性,如下所示:

int i;
_int8 codeword[64800];
//loop running through codeword
if (codeword[2 * i] || codeword[2 * i + 1]) {
// more code here
}