Second negative numbers in C++ is represented in 2's complement form. For example (If we assume for simplicity using 1 byte) -2 ==>-( 00000010)=11111101+1=11111110
using bit-wise operators like and & and | show different results :
Code:
#include<iostream> #include<conio.h> using namespace std;
void main() { int c; c=(-2)&(3)&(1); printf("%d",c); getch(); }
11111110 AND 00000011 AND 00000001 = 00000000 the results is 0 not 1 .
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )