I hava a char variable, and i am only interested in the two least significant hex values. How do I loose al the other values? example:
char input = 0xFFFFFFD1;
I want:
output = 0xD1;
I tried:
output = (input&0x000000FF);
but than I just get:
output = 0xFFFFFFD1
How do i solve this challenge?
It is very likely that
charis 8-bit on your platform. In which case, this:is the same as this:
I’m also assuming that
outputis of typeint. In which case, you need this:Demo: http://ideone.com/FOdRG.
[If this is not the problem, then you will need to update your question to include the actual code you’re using.]