Search code examples
bit-manipulationlow-level

What is the inverse of this bitwise shift?


The following statement gives me the value 1 (when I print it with %d). How can I do the opposite of this and give it 1 and it returns me 0x1234? Is this possible?

(0x1234 & 0xF000) >> 12

Solution

  • (0x1FFF & 0xF000) >> 12
    

    Will also gives 1. So the answer is no, you cannot go back to the original value