how do you reverse and rotate hex numbers and return the number in C with bitwise operators?
for example:
0xabcd -> 0xdcba
0xabcd -> 0xdabc
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.
It’s hard to know where to begin with this question. Plus I smell homework.
Some points:
There is no such thing as a “hex number”. Hex is just a notation. How do you reverse and rotate decimal numbers and return the number in C? For example:
To solve this problem, you need a deep understanding of positional notation, whether it’s base 10, base 16, base 2, or what have you.
All you need can be had by adding, subtracting, multiplying, and dividing. Those are operations on numbers. Modulus is also very helpful.
If you happen to want to multiply or divide by a power of two, I commend to you the C left shift
<<and right shift>>operators. These work perfectly for numbers that are represented using the C typesunsignedorunsigned long.