/*short型:*/
unsigned short swapShort16(unsigned short shortValue){
return ((shortValue & 0x00FF ) <<8) | ((shortValue & 0xFF00)>>8);
}
/*int型:*/
int swapInt32(int intValue){
int temp = 0;
temp = ((intValue & 0x000000FF) <<24)|
((intValue & 0x0000FF00) <<8) |
((intValue & 0x00FF0000) >>8) |
((intValue & 0xFF000000) >>24);
return temp;
}
/*float型:*/
float swapFloat32(float floatValue){
typedef union SWAP_UNION{
float unionFloat;
int unionInt;
}SWAP_UNION;
SWAP_UNION swapUnion;
swapUnion.unionFloat = floatValue;
swapUnion.unionInt = swapInt32( swapUnion.unionInt);
return swapUnion.unionFloat;
}
/*double型换一种写法,用一下指针,不然移位移死了……*/
void swapDouble64(unsigned char *pIn, unsigned char *pOut){
for( int i=0;i<8;i++)
pOut[7-i] = pIn[i];
}