Skip to content

Instantly share code, notes, and snippets.

@sachin-handiekar
Created October 16, 2011 20:07
Show Gist options
  • Save sachin-handiekar/1291357 to your computer and use it in GitHub Desktop.
Save sachin-handiekar/1291357 to your computer and use it in GitHub Desktop.
Bitwise Operators
/* * Operator 4 : Bitwise Operators. */
#include "iostream"
#define PRINT(int) printf("%d\n",int)
using namespace std;
int main()
{
int x,y,z;
x = 03, y = 02, z= 01;
PRINT(x | y & z);
PRINT(x | y & -z);
PRINT(x ^ y & ~z);
PRINT(x & y && z);
x = 1;
y = -1;
PRINT( !x | x);
PRINT( ~x | x);
PRINT( x ^ x);
x = 3;
PRINT(y);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment