tags:

views:

126

answers:

6

what does this sybol means please? "<<" for example: if (1 << var)

I want the name of the thing to study. Thank you.

+3  A: 

The name is The C Programming Language.

liori
+1 for referring Alan to a good resource (instead of whatever he is using) ... but maybe (just maybe, I don't believe it) the OP already has a copy of The C Programming Language.
pmg
+5  A: 

It shifts the bits in the integer 1 var positions to the left. So in effect it calculates 2 to the power of var.

See the article on bit shifts on wikipedia.

sepp2k
+4  A: 

That's the left bitwise shift operator.

The other bitwise shift operator is >>.

pmg
+2  A: 

It is the left shift operator.

You might want to read about bitwise operations, and more specifically, bitshift operators.

Bertrand Marron
+1  A: 

<< is a bit manipulation operator. Specifically << performs left shift operation. This achieves the effect of multiplying the underlying value by power of 2.

More information could be found at: http://en.wikipedia.org/wiki/Bit_manipulation

kuriouscoder
+3  A: 

That is a "left bit shift" operator. In your example, it shifts 0000..00001 left "var" places. So if var is 1, this is the same as "1 << 1" which shifts 0001 to 0010, which is 2. If var was 2 the answer would be 0100 (4), etc. If this isn't making sense, you'll need to read up on binary arithmetic.

SoapBox