Reputation: 1
The teacher gave us this question and I couldn't answer it and I hope to get here some help.
Perform the following logic operation:
1- AB5D AND CD5F
2- DD1D XOR B159
And I want to know the step that I should follow to find the right answer.
Upvotes: 0
Views: 151
Reputation: 28676
Convert the individual hex characters to binary, put them over one another, and for each column, if both are 1, the result will be one; in all other cases, the result will be zero. Write this down below the two other binary strings. Then, when you have done this for all digits, convert it back to hex.
Example:
A = 1010
C = 1100
----
1000 = 8
There is your first digit of ANDing AB5D and CD5F. Keep doing it like that, and you'll get it.
The XOR operation gives a 1 where EITHER one or the other digit is 1, but not both.
It'd be worthwhile to brush up on all your bitwise operations, as well; they can all be done the same way.
Upvotes: 2
Reputation: 12245
0xAB5D AND 0xCD5F = 0x895D
0xDD1D XOR 0xB159 = 06C44
Use 'calc' in windows or 'gnome-calculator' in GNOME linux or just Pyrhon / Ruby it.
UPD: if you wanna do this on the paper, follow next few easy steps:
Upvotes: 0
Reputation: 240
The members are in hexadecimal (AB5D, CD5F, ...), so it's easier if you transform them in binary before. You can use this table:
0 = 0000 4 = 0100 8 = 1000 C = 1100
1 = 0001 5 = 0101 9 = 1001 D = 1101
2 = 0010 6 = 0110 A = 1010 E = 1110
3 = 0011 7 = 0111 B = 1011 F = 1111
So, AB5D is 1010101101011101
.
And then you apply the bitwise operations. It means the result of, for example, A XOR 3
is:
A XOR 3 =
1010 XOR 0011 =
1001 =
9 (see conversion table)
Upvotes: 3