What does bit shifting a byte array element do in C

160 views Asked by At

I am trying to understand this bit of code.

uint8_t input[4];//Just the relevant bits of code here
unsigned int s = (input[0] << 24) | (input[1] << 16) | (input[2] << 8) | input[3];

So I guess my main question is, is it relevant to keep the first two bit shifts? I really don't know exactly what is going on here. As far as I knowt the first shift is a 24 bit right shift on the first element of the input array which is then OR'd with the next element. But won't this always just be zero since the element is only 8 bits in length? Or am I missing something.

0

There are 0 answers