I have this naive question:
A double
is 8 Bytes even on 32 bit machines, also long long
, and we know that the pointer size on that implementation is just 4 Bytes. Because that has a relationship with the processor's register size. So a processor register must be able to address any data type.
Here is my code, run with compiler flag -m32
:
std::cout << "size of double: " << sizeof(double) << '\n'; // 8
std::cout << "size of double*: " << sizeof(double*) << '\n'; // 4
So how can a pointer to
double
of4 Bytes
point to8 Bytes
(double object
)?On 64 bit systems the size of a pointer is 8 Bytes so it is OK. Does this mean
double
works more effectively on 64 bit systems than on 32 bit ones?