Trying to figure out how this works but I cannot wrap my head around what i is representing. I understand that we assign an unsigned long long because it contains the same number of bits as a float. But what exactly does i stand for?
My best interpretation is that we are trying to cast the double number to an unsigned long long int because they have the same number of bits. And it appears that the best way to do so is to dereference the pointer we have set up?
Any help will be greatly appreciated!
void printDouble(double d) {
unsigned long long int i = *(unsigned long long int *)&d;
for (int j = 63; j >= 0; j--) {
std::cout << ((i >> j) & 1);
if (j == 63) std::cout << " ";
else if (j == 52) std::cout << " ";
}
}