I have a integer value which, when some condition are met, must be modified like in this example :
00000001 10000000 11111111 00000000
becomes
11111111 00000000 00000001 10000000
The first 16 bit word must become the second and vice-vera. I know I can easily convert my long into a array of 0 and 1 and then I could use powers of 2 to reconstruct the long that I way I need it, but I was wondering is there was any other, better and faster way to do it. By faster I mean execution wise. If it’s more complicated but have a better result, it’s still fine with me.
thanks
You can do it with shifts and bitwise or: