I have an integer defined in hex, like:
int number = 0x000500000;
Is it possible to get the value of a digit? For example, I want to know the value of the 5th digit (reading from right to left, though either direction would work great for me). Something like:
public int valueOfDigit(int value, int position) {
return value at position'th digit of value;
}
How can I do that? (Not sure if digit is the right term here, please correct me if wrong),
Thanks
Well, a hex digit is 4 bits, so basically it’s just a case of shifting and masking: