On 9 Mar 2006, Paulo Matos wrote: > I'd like to have access to 64 bits. I think unsigned long long is 64 > bits in g++ although I'm not sure. Is there a way to know which type is > 64 bits long or not?
Try this: $ cat > longlong.C #include <cstdio> int main() { unsigned long long a=0; printf("long long is %d bytes (%d bits).\n", sizeof(a), sizeof(a)*8); a+=0xAFFE; return 0; } $ make longlong g++ -L/usr/X11R6/lib -lX11 -lm longlong.C -o longlong $ longlong long long is 8 bytes (64 bits). > Still, even if I know that unsigned long long is 64 bits long, how can > I know that it will occupy only two registers in a 32bit PC, or 1 > register in a 64bit PC? Is there a way to make sure a 64 bit value, be > it an unsigned long long or a unsigned char v[8] to be kept on 2 > registers or 1 in 32 bit or 64 bit PC respectively? $ g++ longlong.C -S $ cat longlong.s [... you will find among the 40 lines output (on intel CPU systems) lines like : ] leal -8(%ebp), %eax addl $45054, (%eax) adcl $0, 4(%eax) Where 45054 (dec., which is 0xAFFE hex) is added in two steps (LSB=45054, MSB=0) to the variable "a" (stored at -8(%ebp), then %eax). If I had an installation where "g++ -m64" works, I could compare the results. Maybe you can do it (using "diff" on the *.s files produced with and without that option) yourself with these indications. PS: The precise answer (if needed) to your question is: The value is kept in 8 consecutive bytes, longlong-word aligned, in the memory, no matter if your system is "32 bit" or "64 bit". But operations are executed 32-bit wise here. My example doesn't involve CPU registers (except for pointers). _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus