I read a few topics that already split doubles and โunite them,โ but I'm trying to break it down into basic components. While I beat the beat:
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 confused about how to get the exponent and the mantissa. I left with forcing the double to the long, because only the leading bit mattered, so truncation did not play a role. However, with other parts, I donโt think this will work, and I know that you cannot do bitwise operators on floats, so I am stuck.
Thoughts?
edit: of course, as soon as I post it, I find it, but I'm not sure if in this case the different floats are doubled.
Edit 2 (sorry for the work when I leave): I read this post that I linked in editor 1, and it seems to me that I can perform the operations that they perform on my double the same path, with masks for the exponent:
mask = 0x7FF0000000000000L;
and for the mantissa:
mask = 0xFFFFFFFFFFFFFL;
Is it correct?
source share