Videos
All integers are made up of binary. And char is made up of an integer, which is made up of binary, so it's technically a "higher order data type" than it's int and long primitive relatives.
It sounds nitpicky, but isn't everything beyond a boolean or a group of booleans a composite data type? Shouldn't booleans be the only primitive type?
The answer is no, and for 2 reasons.
- The notion of primitive types in Java exists by opposition to object types. This has no sense in C which is not an object language.
- C intends to be as efficient as possible on any architecture, from 16 or even 8 bits microcontrollers to 64 bits platforms. For that reason the
inttype is generally chosen as the natural type for the architecture provided it contains at least 16 bits. On the other hand, Jave targets maximum portability and fixes the size of all its types.
So even if the list on Wikipedia looks large, it is (unfortunately...) accurate.
C appears to have many, many types, but what if any are considered primitive types.
The Java term "primitive type" distinguishes from reference types. C has no direct analog of Java's reference types, so no need to draw such a distinction.
C does, however, define several categories of types, and among those, the basic types are a reasonably good analogue of Java's primitive types. This category comprises char, the signed and unsigned integer types, and the floating[-point] types. It is ultimately from these, the enumerated types, and type void that all other types are derived, including array types, structure and union types, pointer types, atomic types, and function types.
The basic types can include implementation-defined types, and therefore cannot be exhaustively listed, but those defined by the language spec are:
char
The standard signed integer types
signed char, short int, int, long int, long long int
The standard unsigned integer types
_Bool, unsigned char, unsigned short int, unsigned int, unsigned long int, unsigned long long int
The real floating types
float, double, long double
The complex types
float _Complex, double _Complex, long double _Complex
This is covered in section 6.2.5 of the language spec.
It should be noted that whereas Java specifies the the size and representation of its primitive types, C leaves some of those details of its basic types to implementations, placing constraints on their ranges of representable values and other properties without specifying exact details.
C appears to have many, many types
C has an unbounded number of types, as it provides for types to be derived from other types. The same applies to Java. Ignoring implementation-defined extension types, C has more than twice as many basic types as Java has primitive types, but that's still manageable, especially given the way they are organized.
However, C also has a mechanism for defining type aliases, and a whole family of standard type aliases, and these can make it appear that there are more types than really there are.