How to swap the nibble bit positions of a number?
For example: 534, convert it into binary, the rightmost 4 bits has to be interchanged with the leftmost 4 bits and then make a new number with that.
Anyone know how to do this?
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.
Start from the fact that hexadecimal
0xfcovers exactly four bits. There are four nibbles in a 16-bit number. The masks for the nibbles are0xf000,0xf00,0xf0, and0xf. Then start masking, shifting and bitwise OR-ing.