integer size in c depends on what?

It’s implementation-dependent. The C standard only requires that:

  • char has at least 8 bits
  • short has at least 16 bits
  • int has at least 16 bits
  • long has at least 32 bits
  • long long has at least 64 bits (added in 1999)
  • sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long) ≤ sizeof(long long)

In the 16/32-bit days, the de facto standard was:

  • int was the “native” integer size
  • the other types were the minimum size allowed

However, 64-bit systems generally did not make int 64 bits, which would have created the awkward situation of having three 64-bit types and no 32-bit type. Some compilers expanded long to 64 bits.

Leave a Comment