O
OSHIMA
Hi,
I found the swap() function without a temporary variable.
void swap(int *x, int *y){
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
So, I wrote the next code that exchange the double.
void dswap(double *x, double *y){
*(int *)x ^= *(int *)y;
*((int *)x + 1) ^= *((int *)y + 1);
*(int *)y ^= *(int *)x;
*((int *)y + 1) ^= *((int *)x + 1);
*(int *)x ^= *(int *)y;
*((int *)x + 1) ^= *((int *)y + 1);
}
But it is dirty. Does it rewrite more simply?
I found the swap() function without a temporary variable.
void swap(int *x, int *y){
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
So, I wrote the next code that exchange the double.
void dswap(double *x, double *y){
*(int *)x ^= *(int *)y;
*((int *)x + 1) ^= *((int *)y + 1);
*(int *)y ^= *(int *)x;
*((int *)y + 1) ^= *((int *)x + 1);
*(int *)x ^= *(int *)y;
*((int *)x + 1) ^= *((int *)y + 1);
}
But it is dirty. Does it rewrite more simply?