Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在c中向左移位位值 使现代化_C_Microcontroller - Fatal编程技术网

在c中向左移位位值 使现代化

在c中向左移位位值 使现代化,c,microcontroller,C,Microcontroller,我是新的硬件编程与c编译器的PIC18F4550从微芯片 我的问题是,有人能给我举个例子‘如何用进位向左移位’1110=>14吗 比特是要去的地方的标志。另外,这个数字应该减少一点。我希望这是清楚的,提前道歉 unsigned int red=1206420333240; LATAbits.LATA2=红色未测试的基本版本 unsigned result = 0; index = 0; while (1) { if (result > UINT_MAX / 2) /* there

我是新的硬件编程与c编译器的PIC18F4550从微芯片

我的问题是,有人能给我举个例子‘如何用进位向左移位’1110=>14吗

比特是要去的地方的标志。另外,这个数字应该减少一点。我希望这是清楚的,提前道歉

unsigned int red=1206420333240;
LATAbits.LATA2=红色未测试的基本版本

unsigned result = 0;
index = 0;
while (1) {
    if (result > UINT_MAX / 2) /* there will be carry on the next operation! */;
    result *= 2;
    result += data[index];
    index++;
    /* this loop needs a break somewhere */
}

你的问题我不太清楚

您想知道如何将整个数组左移,其中每个整数表示一位(例如:{0,0,1,0}=>{0,1,0,0})? 如果是,可以尝试以下操作(假设:数组不为空):

inti;
int arraySize=sizeof(data)/sizeof(int);//您可以使用sizeof(data[0])更改sizeof(int)
整数进位=数据[0];
对于(i=1;i
位从何而来?一个整数数组,值的排他性
0
1
?顺序相反(低位在低位地址)?…不,我完全不清楚。请重新开始。我更新了问题。抱歉!请给我们一个完整的示例,包括输入、输出和小说明。
int i;
int arraySize = sizeof(data) / sizeof(int); // You can change sizeof(int) with sizeof(data[0])
int carry = data[0];
for (i = 1; i < arraySize; i++)
   data[i - 1] = data[i];