I am doing a program to check the sign of a double/float number, first of all I cast the pointer of the number into a long int, then I check the sign bit if it's 0 or 1. I don't understand why the printing of the sign bit with this operation *pointer >> 63 is -1 instead of 1?(assuming *pointer is the int64_t that I casted my double/float into)
This is the entire code :
double d = -0.0;
int64_t *pointer = (int64_t *) &d;
if (*pointer >> 63)
printf("negative number\n");
else
printf("positive number\n");
// if i print the result of (*pointer >> 63), it gives me -1
// so how can this go inside my if condition?
By the way the binary printing of -0.0 in 64 bits gives me 100000000...000