I've read a few topics that do already broken down doubles and "puts it together" but I am trying to break it into it's base components. So far I have the bit nailed down:
breakDouble( double d ){
long L = *(long*) &d;
sign;
long mask = 0x8000000000000000L;
if( (L & mask) == mask ){
sign = 1;
} else {
fps.sign = 0;
}
...
}
But I'm pretty stumped as to how to get the exponent and the mantissa. I got away with forcing the double into a long because only the leading bit mattered so truncation didn't play a role. However, with the other parts I don't think that will work and I know you can't do bitwise operators on floats so I'm stuck.
Thoughts?
edit: of course as soon as I post this I find this, but I'm not sure how different floats and doubles are in this case.
Edit 2(sorry working as I go): I read that post I linked in edit 1 and it seems to me that I can perform the operations they are doing on my double the same way, with masks for the exponent being:
mask = 0x7FF0000000000000L;
and for the mantissa:
mask = 0xFFFFFFFFFFFFFL;
Is this correct?