Integer Length for Intel Core 2 Duo (MAC OSX)

AI Thread Summary
The discussion centers on determining whether an Intel Core 2 Duo machine running Mac OS X is 32-bit or 64-bit based on output from a C program. The output shows that the integer type is 32 bits, leading to confusion about the machine's architecture. It is clarified that an `int` is typically 32 bits even on a 64-bit system, while `long long` is 64 bits. The compiler settings are crucial, as the code may be generating 32-bit output instead of 64-bit, which can be adjusted with specific compile options. Overall, the expected sizes for other types like `float` and pointers are consistent with 64-bit architecture, but the compiler's configuration must be verified.
cjm2176
Messages
8
Reaction score
0
Hello all,

I am trying to determine if my machine is 64 bit or 32 bit, according to this site:

http://support.apple.com/kb/ht3696"

the Intel Core 2 Duo I am using is 64 bit, but when I run the following code

Code:
#include <stdio.h>

int main(int argc, char **argv)
{
  char c;
  int  i;
  float f;
  double d;
  long l;
  long long ll;
 
  printf("char %ld, int %ld, long %ld, long long %ld, float %ld, double %ld, pointers %ld\n",
  8*sizeof(c),
  8*sizeof(i),
  8*sizeof(l),
  8*sizeof(ll),
  8*sizeof(f),
  8*sizeof(d),
  8*sizeof(&c));
}

I get the output:

char 8, int 32, long 32, long long 64, float 32, double 64, pointers 32

If my machine is 64 bit should I be getting int 64 instead of int 32? If yes could this be a problem? I am using GNU compilers, i.e. gcc.

Thanks
cjm2176
 
Last edited by a moderator:
Technology news on Phys.org
No, int is 32 bits. long long int would be a 64 bit signed integer. or compile with the -m64 switch (or is it -arch x86_64 on mac? something like that)
 
Last edited:
Ok thanks, are the other types the expected length for 64 bit? such as float and pointer?
 
cjm2176 said:
Ok thanks, are the other types the expected length for 64 bit? such as float and pointer?
The code you showed has more to do with the code that the compiler generates than with the size of a register on your computer.

32 bits for a float is pretty standard and 64 bits for a double, which you didn't check. The fact that your compiler reports that a pointer is 32 bits makes me think that your compiler is generating 32-bit code.
 
I tested your source code on Windows XP X64, using Microsoft Visual Studio (2005) in 64 bit mode, the only difference is that the pointers are 64 bit. Check to see if your compiler has a 64 bit compile option. For Visual Studio, the project build configuration has to be set to x64 to get 64 bit mode.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Back
Top