If any of you have viewed the Sun microsystems fdlibm source this code might look familiar. I'm porting it around but the only trouble is I'm unsure exactly what this little snippit does:
The literal translation of this code is obvious, it just takes the address of the double and shifts it by one byte then dereferences it. This supposedly gets the high order bits of the double. I'm wondering if anyone has a more friendly way of doing this. The confusion for me is that doubles are stored in memory in a way that is compiler specific yet this code is portable. Any takers?Code:double a = 24.364536457; // Some number, doesn't really matter int b = *(1 + (int *)&a);



LinkBack URL
About LinkBacks



