Meaning of << operator in C -


this question has answer here:

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

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -