Meaning of << operator in C -
this question has answer here:
- c - syntax about? << 6 answers
i wondering know meaning of operator << in
#define x (10 * (1<<12));
it's bitshift operator. << shift left, >> shift right. 1 << 12 means shift value (the int '1') 12 bits left.
'1' 00000000 00000000 00000000 00000001 in binary, if it's 32 bit integer. shift left 12 places, changes to: 00000000 00000000 00010000 00000000
if shift 5 << 8, '5' 101 in binary, it'll shift:
00000000 00000000 00000000 00000101 into:
00000000 00000000 00000101 00000000 see this question details on other bitwise operators.
Comments
Post a Comment