0

Is it right to say that the width of int data type depends on the data width of the ALU ? For example is it right to say that a 32-bit processor will have int data type as 32-bit wide? Similarly for 16 bit and 8 bit(please note that C guarantees that the size of int at least greater than 16 bit).

bubble
  • 3,408
  • 5
  • 29
  • 51
  • Many processors haven't had distinct ALUs for some time now, so you can't really use that as a reference. Instead it might be better to use the processor internal data-bus width. – Some programmer dude Mar 29 '12 at 09:29
  • 1
    check the link: http://stackoverflow.com/questions/2331751/does-the-size-of-an-int-depend-on-the-compiler-and-or-processor – Vijay Mar 29 '12 at 09:30
  • here is another, almost a duplicate: http://stackoverflow.com/questions/9689049/what-decides-the-sizeof-an-integer – Pavan Manjunath Mar 29 '12 at 09:41
  • @peter thanks for the link. That contains a really good explanation of what i am asking. Please also consider the question in the light of 8-bit architectures. – bubble Mar 29 '12 at 10:20
  • @JoachimPileborg cant understand you properly. Please explain a bit more – bubble Mar 29 '12 at 11:47

2 Answers2

4

No, this is up to the implementation. For instance, many compilers for 64bit systems have 32bit wide ints still.

harald
  • 5,976
  • 1
  • 24
  • 41
1

You would probably have to refer to you compiler's documentation regarding the determination of the size of a primitive type since the details of primitive types and built-in operators such as sizeof would be compiler-specific. In the end it probably would be directly correlated to the details of the hardware, but I believe C is at a higher level of abstraction than concerning yourself with ALU details.

Preet Kukreti
  • 8,417
  • 28
  • 36