此代码将unsigned long
向量变量转换cR1
为NB_ERRORS
数字(在a
变量中我打印这些数字)。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int EXT_DEGREE = 8;
int NB_ERRORS = 8;
int BIT_SIZE_OF_LONG = 32;
typedef unsigned short gf_t;
int main(void){
int j, k, l;
gf_t a;
unsigned long cR1 [] = {418636844,2037720909}; //example
for (l = 0; l < NB_ERRORS; ++l) {
k = (l * EXT_DEGREE) / BIT_SIZE_OF_LONG;
j = (l * EXT_DEGREE) % BIT_SIZE_OF_LONG;
a = cR1[k] >> j;
if(j + EXT_DEGREE > BIT_SIZE_OF_LONG)
a ^= cR1[k + 1] << (BIT_SIZE_OF_LONG - j);
a &= ((1 << EXT_DEGREE) - 1);
printf("a = %d\n", a);
}
例如,我有一个 cR1 数组,其中包含以下两个元素:
0,0,1,1,0,1,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1,0,0,0
1,0,1,1,0,0,1,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,0,1,1,1,1,0
执行该代码我得到:
a = 44
a = 228
a = 243
a = 24
a = 77
a = 39
a = 117
a = 121
这段代码从右到左转换,我想修改为从左到右转换。我可以在哪里修改这个?