[slang-users] Reg bitwise &
John E. Davis
davis at space.mit.edu
Tue Oct 31 23:29:08 EST 2006
Ajay Kumar <Ajay.Kumar at omantel.om> wrote:
>Int1 = (25 & 1)
>Int2 = (25 & 2)
>Int3 = (25 & 4)
>
>Int4 = (26 & 1)
>Int5 = (26 & 2)
>Int6 = (26 & 4)
>
>What is expected return values in the IntX specified above? How does
>slang proceeds with calculating the values.
The binary representations of the above numbers are given in the
following table:
1 00001
2 00010
4 00100
25 11001
26 11010
So:
Int1 = 25&1 = 00001 = 1
Int2 = 25&2 = 00000 = 0
Int3 = 25&4 = 00000 = 0
Int4 = 26&1 = 00000 = 0
Int5 = 26&2 = 00010 = 1
int6 = 26&4 = 00000 = 0
If you are getting different values, then there is a problem.
--John
More information about the slang-users-l
mailing list