Please explain

Feb 9, 2015 at 6:55pm
This code prints 32 at the output but can you please tell me how it is 32??

printf("%d", 2<<6>>2);
Last edited on Feb 9, 2015 at 6:55pm
Feb 9, 2015 at 7:06pm
The bitshift operators. Check them out.
Feb 9, 2015 at 8:00pm
1
2
3
4
5
6
7
8
9
10
11
12
00000010   <-  2 in binary

00000100   <-  left shift 1
00001000   <-  left shift 2
00010000   <-  left shift 3
00100000   <-  left shift 4
01000000   <-  left shift 5
10000000   <-  left shift 6

00100000   <-  right shift 2

00100000   <-  32 in binary
Feb 9, 2015 at 8:07pm
@Disch Thanks bro..I was stupidly calculating 2 bitshifts at the same time..Marking it as solved..:)
Last edited on Feb 9, 2015 at 8:08pm
Topic archived. No new replies allowed.