Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does this line do? 1

Status
Not open for further replies.

totaljj

MIS
May 3, 2006
3
GB
Could you explain what does below line do to l.
For example if i=0 and j=0 what's the value of l.


l = ((i>>3)&1) ^ ((j>>3)&1) ;

 
Oh, btw, in your case the value should be 0, but the best way to know is compile and execute :)

Cheers,
Dian
 
i believe l will be 0 for any value of i and j becuase
for example
if i= 00011 (3) j=00001 (1) then 3 right shift will do i=11000 j=01000
and & with 1 will do
i=0 j=0 and
xor 0=l
I don't understand why using this rather than computational speed up.
is there any equivalent ordinary formula.
I can see i>>3=i*8 but what about & and ^?
 
I've got the idea now.
It is not shifting the actual value but the target.
so 0001>>3 would be 0 at the first and adding it with 1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top