Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
if i am doing
HTML
 Statement        Result
select 1&1          1
select 1&2          0
select 1&3          1
select 1&4          0
select 123&1        1
select 123&7        3
select 1234&789     16
select 789&1234     16
select 78&12346     10
select 12345&678    32


Means?? Please help me..!!
Posted
Updated 29-Mar-14 1:01am
v2

& is the bit wise AND so 1&2 (decimal) == 01 and 10 (binary) = 0 etc.
 
Share this answer
 
Comments
OPees 29-Mar-14 7:10am    
Thank you :)
"&" is a binary AND operator: it combines bits in the operand, so if the bit is one in both operands, than the result is the same bit one - other wise it is zero.
So, for each bit:
Op1  &   Op2   Result
 0        0       0
 0        1       0
 1        0       0
 1        1       1
It's kind hard to see from your example what is going on, because all your numbers are in decimal - which doesn't relate "nicely" to the actual bits. But...if you translate them to binary values first it's more obvious:
Your command       Op1             Op2            Result
select 1&1          01              01               1
select 1&2          01              10               0
select 1&3          01              11               1
select 1&4         001             100               0
select 123&1   1111011         0000001               1
select 123&7   1111011         0000111              11
etc.
 
Share this answer
 
Comments
King Fisher 29-Mar-14 7:10am    
My 5+. mr.griff
OPees 29-Mar-14 7:10am    
Thank you :)
OriginalGriff 29-Mar-14 7:16am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900