Skip to content

Instantly share code, notes, and snippets.

@j2doll
Last active August 12, 2017 08:59
Show Gist options
  • Save j2doll/1923063ad945b76ae16503b94beab98b to your computer and use it in GitHub Desktop.
Save j2doll/1923063ad945b76ae16503b94beab98b to your computer and use it in GitHub Desktop.
Demonstrate shift operators
// shift.cpp
// code from MSDN
// Demonstrate shift operators
#include <iostream>
using namespace std;
int _tmain() {
 cout << "5 times 2 is " << (5 << 1) << endl; // 5 × 2 = 10
cout << "20 divided by 4 is " << (20 >> 2) << endl; // 20 ÷ 4 = 5
 return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment