i have a little problem i want to make 32 bit swap i have this number 0x 434232340a4cd995 and i want it to be ox 0a4cd99543423234 here is my code but it doesn't work right
1 2 3 4 5 6
void main()
{
longlong data =0x434232340a4cd995;
data = (data ^ data & 0xff) | ((data & 0xf) << 32) | ((data & 0xf0) >> 32);
printf(" %x \n", data);
}
When you say swap you mean something different than this:
There are 2 variables with some values and at the end of swapping each variable should contain the value of the other?
You want to make a circle through your number (I am not sure this is called swapping but anyway), correct?
Why don't you use something like: data = (data << 32) | (data >> 32);(data << 32) should give 0a4cd99500000000 if your implementation for longlong uses 64 bit (otherwise it won;t work of course) and (data >> 32) should give 0000000043423234.
By using bitwise OR the result should be OK.
(maybe I am missing something here but if not it should work)