how to do a simple swap of two half of a 32bit integer in c
10:53 05 Nov 2025

i am trying to figure out a code that would be able to swap the higher half and the lower half of the binary form of an integer number such as for example:

0000000 00110011 01001001 11111110 turn into 01001001 11111110 00000000 00110011.

i tried using bit wise operators and made an attempt at a function for this purpose

int inverse_half(unsigned int x){
    int high;
    int low;
    
    high = x >> 16;
    low = x & 0xFFFF;
}
c binary