Вопрос

tempValue = input2[0] << 8;

I can't figure out what the << does in this line of code. What is this used for?

Это было полезно?

Решение

It assigns tempValue the value in input2[0] shifted to the left by 8 bits.

Here is a link about bit shifting in C: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/bitshift.html

Другие советы

You can google Bitwise Operation for many information.

In your case, input2[0] being Left shift(<<) for 8 bits, which is * (2^8).

So, equivalent tempValue = input2[0] * (2^8) ;

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top