PDA

View Full Version : how can i perform bitwise AND operation of two binary numbers?



aurora
5th March 2012, 07:53
how can i perform bitwise and operation on two binary numbers?
Ex: A-->1101
B-->1011
Then A AND B-->1001

I tried like this but getting compilation error saying that error: request for member 'operator&' in 'bin_celVal', which is of non-class type 'int'

what changes i have to do here?

int bin_celVal=BinVal(PrCell);
int bin_Val=BinVal(Val);
int ANDresult= bin_celVal.operator &(bin_Val);
cout<<"RESULT:"<<ANDresult<<endl;

wysota
5th March 2012, 08:38
int ANDresult = bin_celVal & bin_val;