I have short integer i need to reverse the bits in it ie first 8 bits in the second 8 bits position and second 8 bits in first 8 bit position?
[b]Question asked by visitor Philip[/b]
Printable View
I have short integer i need to reverse the bits in it ie first 8 bits in the second 8 bits position and second 8 bits in first 8 bit position?
[b]Question asked by visitor Philip[/b]
short int x,y; ( 16 bit )
y = x && 0X00ffh ;
x = x && 0X0ff00h ;
x = x << 8 ;
y = y << 8 ;
x = x || y;
Printf(" Exchange value is in x = %d",x);
How to reverse the bits in a short integer in Java
[CODE]
int x = i & 0x00FF;
int y = i & 0xFF00;
x = x << 8;
y = y >> 8;
System.out.println("");
System.out.println(x | y);[/CODE]
Logic remains same.... (there's some typo in the above post, I guess)...
-dibyaranjan