I wrote such code example:
int main(void) {
double f = 0.1;
int i, j;
i = *(int *)(&f);
j = (int)f;
printf("%d\n%d\n", i, j);
return 0;
}
And I expected that the results will be the same. Because I thought that generally these are the same things: to reinterpret data of one type as data of another type and take a pointer of one type, cast it to pointer of another type and then access the data. But I got:
-1717986918
0
What is the reason? Sorry, if obvious.