Are These All The Integer Types In C

Hello and Good day, I am currently studying C and I just finished learning about variables mainly those of integer type.

I am wondering if the list below are all there is to integer variables and there are still more that i have to learn.

Here are the list:
Char
Short
int
long
long long

float
double
long double.

The only parts you didn't mention are signed vs unsigned, pointers, and bitfields. Pointers on most modern systems are all the same size, related to the system's address size, i.e. 32-bit on 32 bit systems, 64-bit on 64.

Note that "long long" and "long double" are nonstandard types, unavailable on many systems. "long long" particularly is no longer needed to get a 64-bit type, 'long' has become natively 64-bit on modern 64-bit computers (except on Windows for some reason).

Also, the exact number of bits in 'char', 'short', 'int', and 'long' are not rigidly defined by the language, they're a fact of the processor you use it with, though even there they're sometimes interpreted differently from publisher to publisher. There was a compiler for a strange Cray supercomputer which had no types smaller than 64 bits!

Bitfields are a rarely-used feature which can make an integer of an arbitrary number of bits (probably up to the system word size.) int y:4; Voila, a 4-bit integer which can represent values from -8 to +7. This feature is mostly avoided as it's slow and wasteful of space. I've only seen it used exactly once -- to make ersatz 32-bit integers for that strange Cray supercomputer.

1 Like

Hi Corona688,
The signed, unsigned, and "unadorned" long long int types (i.e., signed long long int, unsigned long long int, and long long int) weren't available in K&R C nor in the first version of the ISO C Standard, but have been ISO C standard types since the 2nd version of the standard (AKA C99).

C99 also added the header <inttypes.h> which requires for a (possibly larger than long long) intmax_t. It also requires the types intN_t and uintN_t where N is 8, 16, 32, and 64 to hold signed and unsigned, respectively, integers of exactly 8, 16, 32, and 64 bits, respectively. It requires that intmax_t be a signed integer type of at least 64 bits and that uintmax_t be an unsigned integer type of at least 64 bits. And, it allows additional N values for any other lengths of integer types supported by your compiler.

I don't know of many compilers that support other lengths, but I have seem plans to develop a compiler that would at least support int96_t, uint96_t, int128_t, and uint128_t on 64-bit architecture hardware.

1 Like

Thanks guys for your contributions.