Data type

Data types are used within type systems, which offer various ways of defining, implementing, and using them. Different type systems ensure varying degrees of type safety.

Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology.

Most data types in statistics have comparable types in computer programming, and vice versa, as shown in the following table:

Parnas, Shore & Weiss 1976 identified five definitions of a "type" that were used—sometimes implicitly—in the literature:

A type is defined in terms of its composition of more primitive types—often machine types.
A type is defined as its representation and a set of operators manipulating these representations.
A type is a set of values which a variable can possess and a set of functions that one can apply to these values.

Primitive data types are typically types that are built-in or basic to a language implementation.

Floating-point numbers used for floating-point arithmetic use a different interpretation of the bits in a word. See Floating-point arithmetic for details.

Many other types are possible, but they tend to be further variations and compounds of the above. In particular, if a field of a record can be a pointer to another record, then quite complicated types can be constructed. Arbitrary use of pointers in a data structure can cause just as much confusion as arbitrary jumps in program code.

Access to the data can be specified by pattern-matching over the three operations, e.g. a member function for these containers by:

Care must be taken to ensure that the function is invariant under the relevant rules for the data type.