The expression
#define __HI(x) *(1+(int*)&x)
is defined in Sun's math library, in fdlibm.h. It is used in most programs of Sun's math library, e.g., in its implementation of sin(x)
double y[2],z=0.0;
int n, ix;
/* High word of x. */
ix = __HI(x);
/* |x| ~< pi/4 */
ix &= 0x7fffffff;
if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0);
In the code above, variable x
is of type double. Can any one explain me the syntax the expression in __HI(x)
. The readme of Sun's library says __Hi(x)
is
"the high part of a double x (sign,exponent,the first 21 significant bits)".
I just do not understand the syntax of *(1+(int*)&x)
, and why it corresponds to x
's higher part. Any clarification?