As we know that truth table of AND is if 2 number is true then only output becomes true. For that reason & is used to find bits on or off.
Harshit Bhatia said:
(Thu, Oct 28, 2010 09:06:53 AM)
Yaa, & operator is perfect for find out on or off.
Madhureddy said:
(Wed, Feb 2, 2011 11:57:10 AM)
Hai frndz. How & operator is used to check whether a bit is on or off is as follows let us conceive that there is a binary num 10101000 if you want to check third bit is on or off then perform and operation to 00001000 then if 3rd bit is 1 its on else its turned off.
Here if wana check nth bit make n-1 bit as 1 remaining as 0. Then perform and operation then you will know the answer.
Siraj said:
(Fri, Feb 4, 2011 12:50:02 AM)
Hey anybody can explain me how & operatoer is used to chek on or off ?
Amit(Saktimaan) said:
(Thu, Mar 3, 2011 05:56:45 AM)
I don't understand this.
Seenu said:
(Sat, Mar 12, 2011 11:27:03 PM)
Hi! Guys this is a simple one. Let consider 8-bit binary number,
Binary(8 bit) = 0000 1100
suppose we want check 3rd bit is on or off(on=1 & off=0), just like this,
0000 1100 (Decimal=12)
&
0000 0100 (Decimal=4,we are checking 3rd bit so it is 1)
----------
0000 0100 (Decimal=4)
----------
If we got some value then checking bit is on,otherwise off.
In C language,
if(12&4)
print("The third bit is on");
else
print("The third bit is off");
Riya said:
(Fri, Apr 29, 2011 12:44:11 PM)
What is the difference between && and & ?
Payal said:
(Mon, May 23, 2011 01:22:20 PM)
&& is a relational operator it compare two values.
Whereas & is logical operator.
Ajendra Singh said:
(Mon, Aug 22, 2011 04:29:37 PM)
Relation operator is used to make an expression to compound one whereas bitwise and is used to operate on bits for faster access.
In detail,,
The key difference between & and && is ,its return value
EX; 1&2 returns zero whereas 1&&2 returns one ..
check out
1=0001 & 0010= 0000 on & opertion
and 1(true) and 2(true) so 1&& 2=1(true)