N
Neil
The program below aims at switch different part of a hexadecimal
number,
e.g, input: 0x12345678,output 0x78563412
but when it comes to 0x98765432, the output becomes 0x32547598 rather
than 0x32547698
Looking forward to a explaination in detail,thx
#include "stdio.h"
int main()
{
long int x,high,low,high8,high16,low16,low8,sum;
printf("Please input a number begin with 0x\n");
scanf("%x",&x);
high=x>>16;
low=x-(high<<16);
high8=x>>24;
high16=high-(high8<<8);
low16=low>>8;
low8=low-(low16<<8);
sum=(low8<<24)+(low16<<16)+(high16<<8)+high8;
printf("\nAfter switch the number is0x%x\n",sum);
return 0;
}
number,
e.g, input: 0x12345678,output 0x78563412
but when it comes to 0x98765432, the output becomes 0x32547598 rather
than 0x32547698
Looking forward to a explaination in detail,thx
#include "stdio.h"
int main()
{
long int x,high,low,high8,high16,low16,low8,sum;
printf("Please input a number begin with 0x\n");
scanf("%x",&x);
high=x>>16;
low=x-(high<<16);
high8=x>>24;
high16=high-(high8<<8);
low16=low>>8;
low8=low-(low16<<8);
sum=(low8<<24)+(low16<<16)+(high16<<8)+high8;
printf("\nAfter switch the number is0x%x\n",sum);
return 0;
}