Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Humza Choudry
237 PointsWhat is the use of >> and << in C
what is the purpose of using >> and how do you implement it into code?
1 Answer
Humza Choudry
237 PointsThanks for the reply. But I'm still not getting a clear picture. If possible can you clarify in anyway or give a different example. Would be of great help. Thanks :p
Omar Sanseviero
8,770 PointsOmar Sanseviero
8,770 PointsIn C, C++ and Objective-C, the >> and << work as a bitwise operation.
Let's say you have this number (we use binary) variable = 0011 1100
new_variable = variable << 1; -> new_variable = 0111 1000
new_variable = variable << 2; -> new_variable = 1111 0000
new_variable = variable << 3; -> new_variable = 1110 0000
new_variable = variable >> 1; -> new_variable = 0011 1100
new_variable = variable >> 2; -> new_variable = 0001 1110
new_variable = variable >> 3; -> new_variable = 0000 1111
It just moves the binary number!