Bitwise Operators between Negative Numbers in C++
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
// Program for Bitwise operator for -ive number
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
int a;
clrscr();
a=((-9&6)^-5)|-7;
cout<<a;
}
/*
1100
0011
1
--------
0100
0101 5
1s 1010
2s +1
-------------
1011 -5
0110 6
&
----------
0010 2
1111 1011 -5
0000 0110 6
|
------------------------
11111111111111111
*/
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

