Importance of Datatypes

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. Common data types include:

integers,

booleans,

characters,

floating-pointnumbers,

alphanumericstrings.

For example, in the Java programming language, the “int” type represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, as well as the operations that can be performed on integers, such as addition, subtraction, and multiplication. Colors, on the other hand, are represented by three bytesdenoting the amounts each of red, green, and blue, and one string representing that color’s name; allowable operations include addition and subtraction, but not multiplication.

Most programming languages also allow the programmer to define additional data types, usually by combining multiple elements of other types and defining the valid operations of the new data type. For example, a programmer might create a new data type named “complex number” that would include real and imaginary parts. A data type also represents a constraint placed upon the interpretation of data in a type system, describing representation, interpretation and structure ofvalues or objects stored in computer memory. The type system uses data type information to check correctness of computer programs that access or manipulate the data.

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

real-valued (interval scale) | floating-point |
---|---|

real-valued (ratio scale) | |

count data (usually non-negative) | integer |

binary data | Boolean |

categorical data | enumerated type |

random vector | list or array |

random matrix | two-dimensional array |

random tree | tree |

Definition of a “type”[edit]

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

SyntacticA type is a purely syntactic label associated with a variable when it is declared. Such definitions of “type” do not give any semantic meaning to types.RepresentationA type is defined in terms of its composition of more primitive types—often machine types.Representation and behaviourA type is defined as its representation and a set of operators manipulating these representations.Value spaceA type is a set of possible values which a variable can possess. Such definitions make it possible to speak about (disjoint) unions or Cartesian products of types.Value space and behaviourA type is a set of values which a variable can possess and a set of functions that one can apply to these values.

The definition in terms of a representation was often done in imperative languages such as ALGOL and Pascal, while the definition in terms of a value space and behaviour was used in higher-level languages such as Simula and CLU.