+ 4
Why does cout << (1<<1) print 2?
I think it should be 0 as 1 is not less than one so false.
3 Answers
+ 2
<< is bit operator(left). 1<<1 will shift one bit left.
which is equivalent to 2.
1 in binary = 0001
after shifting it left(once) = 0010
0 is added after shifting
so 0010= 2
+ 5
<< is a bit shift operator in the context you are using it in. 1 shifted by 1 bit = 2.
You need to do 1 < 1 instead
0
Samanvay lamba i am smarter than you