I have the following hex value store in a variable:
0x04a8f5
I want to convert the value to:
0xff04a8f5
How can I accomplish this?
I’ve tried to do this by the following operation:
int result = 0x04a8f5 >> 8;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the following example as a guideline.
Note, this isn’t bit shifting because if your original value is a 32 bit (or larger) integer, then there is already a higher order byte available that can store the
FFvalue. In other words, your original variable is actually0x0004a8f5. Using an|=assignment will ORFFwith the byte that you are wanting to change. No shifting necessary.Also, shifting
0x0004a8f5by 8 bits would result in0x000004a8.