<< operator in C++?

前端 未结 3 613
遇见更好的自我
遇见更好的自我 2020-12-21 17:10

I am new to C++, what\'s the exact meaning for the << in statement below, Thanks.

if (Val & (0x0001 << 0))
{}
else
{}

3条回答
  •  萌比男神i
    2020-12-21 17:33

    It means shift 0x0001 number 0 bits to the left. In that specific case, it does nothing.

    For example, if it was (0x0001 << 4), 0x0001 would become 0x0010. Each position shifted left is like multiplying the number by 2.

提交回复
热议问题