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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -