TheInfoList

In
computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , , and . Computer science ...
and
computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, generating algorithms, Profilin ...
, a data type or simply type is an attribute of
data Data (; ) are individual facts A fact is something that is truth, true. The usual test for a statement of fact is verifiability—that is whether it can be demonstrated to correspond to experience. Standard reference works are often used ...

which tells the
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily ...

or interpreter how the programmer intends to use the data. Most programming languages support basic data types of
integer An integer (from the Latin Latin (, or , ) is a classical language belonging to the Italic branch of the Indo-European languages. Latin was originally spoken in the area around Rome, known as Latium. Through the power of the Roman Re ...
numbers (of varying sizes),
floating-point In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithm of an algorithm (Euclid's algorithm) for calculating the greatest com ...
numbers (which approximate real numbers),
characters Character(s) may refer to: Arts, entertainment, and media Literature * Character (novel), ''Character'' (novel), a 1936 Dutch novel by Ferdinand Bordewijk * Characters (Theophrastus), ''Characters'' (Theophrastus), a classical Greek set of char ...
and Booleans. A data type constrains the values that an expression, such as a variable or a function, might take. This data type defines the operations that can be done on the data, the meaning of the data, and the way values of that type can be stored. A data type provides a set of values from which an expression (i.e. variable, function, etc.) may take its values.

# Concept

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 In computer science, type safety is the extent to which a programming language discourages or prevents type errors. A type error is erroneous program behaviour caused by a discrepancy between differing data types for the program's constants, variabl ...
. Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. Common data types include: *
Integer An integer (from the Latin Latin (, or , ) is a classical language belonging to the Italic branch of the Indo-European languages. Latin was originally spoken in the area around Rome, known as Latium. Through the power of the Roman Re ...
*
Floating-point In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithm of an algorithm (Euclid's algorithm) for calculating the greatest com ...
number *
Character Character(s) may refer to: Arts, entertainment, and media Literature * ''Character'' (novel), a 1936 Dutch novel by Ferdinand Bordewijk * ''Characters'' (Theophrastus), a classical Greek set of character sketches attributed to Theophrastus M ...
*
String String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * Strings (1991 film), ''Strings'' (1991 fil ...
* Boolean For example, in the
Java programming language Java is a class-based, object-oriented Object-oriented programming (OOP) is a programming paradigm Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing sev ...
, the type ''int'' represents the set of
32-bit 32-bit microcomputers are computers in which 32-bit microprocessors are the norm. Range for storing integers A 32-bit register can store 232 different values. The range (computer programming), range of integer values that can be stored in 32 bi ...
integers An integer (from the Latin Latin (, or , ) is a classical language belonging to the Italic languages, Italic branch of the Indo-European languages. Latin was originally spoken in the area around Rome, known as Latium. Through the power of t ...
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. A color, on the other hand, might be represented by three
byte The byte is a unit of digital information that most commonly consists of eight bit The bit is a basic unit of information in computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It ...
s denoting the amounts each of red, green, and blue, and a string representing the color's name. 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 In mathematics, a complex number is an element of a number system that contains the real numbers and a specific element denoted , called the imaginary unit, and satisfying the equation . Moreover, every complex number can be expressed in the for ...

" that would include real and imaginary parts. A data type also represents a constraint placed upon the interpretation of data in a
type system In programming language A programming language is a formal language comprising a Instruction set architecture, set of instructions that produce various kinds of Input/output, output. Programming languages are used in computer programming to ...
, describing representation, interpretation and structure of
value Value or values may refer to: * Value (ethics) it may be described as treating actions themselves as abstract objects, putting value to them ** Values (Western philosophy) expands the notion of value beyond that of ethics, but limited to Western s ...
s or
object Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Entity, something that is tangible and within the grasp of the senses ** Object (abstract), an object which does not exist at any particular time or pl ...
s stored in computer memory. The type system uses data type information to check
correctness of computer programs In theoretical computer science An artistic representation of a Turing machine. Turing machines are used to model general computing devices. Theoretical computer science (TCS) is a subset of general computer science that focuses on mathematical ...
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:

# Definition

identified five definitions of a "type" that were used—sometimes implicitly—in the literature. Types including behavior align more closely with
object-oriented Object-oriented programming (OOP) is a programming paradigm Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing several related projects * Time management * P ...
models, whereas a
structured programming Structured programming is a programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Some paradigms are concerned mainly with impli ...
model would tend to not include code, and are called
plain old data structure In geography, a plain is a flat expanse of land that generally does not change much in elevation. Plains occur as lowlands along valleys or on the doorsteps of mountains, as coastal plains, and as plateaus or Highland, uplands. In a valley, a pla ...
s. The five types are: ; Syntactic: A type is a purely
syntactic In linguistics Linguistics is the scientific study of language, meaning that it is a comprehensive, systematic, objective, and precise study of language. Linguistics encompasses the analysis of every aspect of language, as well as the ...

label associated with a variable when it is declared. Such definitions of "type" do not give any
semantic Semantics (from grc, σημαντικός ''sēmantikós'', "significant") is the study of reference Reference is a relationship between objects in which one object designates, or acts as a means by which to connect to or link to, another ...
meaning to types. ; Representation: A type is defined in terms of its composition of more primitive types—often machine types. ; Representation and behaviour: A type is defined as its representation and a set of operators manipulating these representations. ; Value space: A type is a set of possible values which a variable can possess. Such definitions make it possible to speak about () unions or
Cartesian product In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
s of types. ; Value space and behaviour: A type is a set of values which a variable can possess and a set of
function Function or functionality may refer to: Computing * Function key A function key is a key on a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...
s that one can apply to these values. The definition in terms of a representation was often done in imperative languages such as
ALGOL Algol , designated Beta Persei (β Persei, abbreviated Beta Per, β Per), known colloquially as the Demon Star, is a bright multiple star in the constellation A constellation is an area on the celestial s ...
and
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, French ...
, while the definition in terms of a value space and behaviour was used in higher-level languages such as
Simula Simula is the name of two simulation A simulation is the imitation of the operation of a real-world process or system over time. Simulations require the use of Conceptual model, models; the model represents the key characteristics or behavio ...
and CLU.

# Classes of data types

## Primitive data types

Primitive data type In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of Algori ...
s are typically types that are built-in or basic to a language implementation.

### Machine data types

All data in computers based on digital electronics is represented as
bit The bit is a basic unit of information in computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithm of an algorithm (Euclid's algo ...
s (alternatives 0 and 1) on the lowest level. The smallest addressable unit of data is usually a group of bits called a
byte The byte is a unit of digital information that most commonly consists of eight bit The bit is a basic unit of information in computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It ...
(usually an
octet Octet may refer to: Music * Octet (music) In music, an octet is a musical ensemble consisting of eight Musical instrument, instruments or voices, or a musical composition written for such an ensemble. Octets in classical music Octets in Europea ...
, which is 8 bits). The unit processed by
machine code In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, ge ...
instructions is called a
word In linguistics Linguistics is the scientific study of language A language is a structured system of communication used by humans, including speech (spoken language), gestures (Signed language, sign language) and writing. Most lang ...
(, typically 32 or 64 bits). Most instructions interpret the word as a
binary number In mathematics and digital electronics Digital electronics is a field of electronics The field of electronics is a branch of physics and electrical engineering that deals with the emission, behaviour and effects of electrons The electr ...
, such that a 32-bit word can represent unsigned integer values from 0 to $2^-1$ or signed integer values from $-2^$ to $2^-1$. Because of
two's complement Two's complement is a mathematical operation In mathematics, an operation is a Function (mathematics), function which takes zero or more input values (called ''operands'') to a well-defined output value. The number of operands is the arity of the ...
, the machine language and machine doesn't need to distinguish between these unsigned and signed data types for the most part. Floating-point numbers used for floating-point arithmetic use a different interpretation of the bits in a word. See
Floating-point arithmetic In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and soft ...
for details. Machine data types need to be ''exposed'' or made available in
system A system is a group of Interaction, interacting or interrelated elements that act according to a set of rules to form a unified whole. A system, surrounded and influenced by its environment, is described by its boundaries, structure and purp ...
s or
low-level programming language A low-level programming language is a programming language A programming language is a formal language comprising a Instruction set architecture, set of instructions that produce various kinds of Input/output, output. Programming languages ar ...
s, allowing fine-grained control over hardware. The
C programming language C (, as in the letter ''c'') is a general-purpose, procedural computer programming language A programming language is a formal language comprising a Instruction set architecture, set of instructions that produce various kinds of Input/outp ...
, for instance, supplies integer types of various widths, such as `short` and `long`. If a corresponding native type does not exist on the target platform, the compiler will break them down into code using types that do exist. For instance, if a 32-bit integer is requested on a 16 bit platform, the compiler will tacitly treat it as an array of two 16 bit integers. In higher level programming, machine data types are often hidden or ''abstracted'' as an implementation detail that would render code less portable if exposed. For instance, a generic `numeric` type might be supplied instead of integers of some specific bit-width.

### Boolean type

The
Boolean typeIn computer science, the Boolean data type is a data type that has one of two possible values (usually denoted ''true'' and ''false'') which is intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole, ...
represents the values
true True most commonly refers to truth Truth is the property of being in accord with fact or reality.Merriam-Webster's Online Dictionarytruth 2005 In everyday language, truth is typically ascribed to things that aim to represent reality or otherw ...
and
false False or falsehood may refer to: *False (logic), the negation of truth in classical logic *Lie or falsehood, a type of deception in the form of an untruthful statement *false (Unix), a Unix command *False (album), ''False'' (album), a 1992 album by ...
. Although only two values are possible, they are rarely implemented as a single binary digit for efficiency reasons. Many programming languages do not have an explicit Boolean type, instead interpreting (for instance) 0 as false and other values as true. Boolean data refers to the logical structure of how the language is interpreted to the machine language. In this case a Boolean 0 refers to the logic False. True is always a non zero, especially a one which is known as Boolean 1.

### Enumerations

The
enumerated type In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, generati ...
has distinct values, which can be compared and assigned, but which do not necessarily have any particular concrete representation in the computer's memory; compilers and interpreters can represent them arbitrarily. For example, the four suits in a deck of playing cards may be four enumerators named ''CLUB'', ''DIAMOND'', ''HEART'', ''SPADE'', belonging to an enumerated type named ''suit''. If a variable ''V'' is declared having ''suit'' as its data type, one can assign any of those four values to it. Some implementations allow programmers to assign integer values to the enumeration values, or even treat them as type-equivalent to integers.

### Numeric types

Such as: * The
integer An integer (from the Latin Latin (, or , ) is a classical language A classical language is a language A language is a structured system of communication Communication (from Latin ''communicare'', meaning "to share" or "to ...
data types, or "non-fractional numbers". May be sub-typed according to their ability to contain negative values (e.g. `unsigned` in C and C++). May also have a small number of predefined subtypes (such as `short` and `long` in C/C++); or allow users to freely define subranges such as 1..12 (e.g.
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, French ...
/
Ada Ada may refer to: Places Africa * Ada Foah Ada Foah is a town on the southeast coast of Ghana, where the Volta River meets the Atlantic Ocean. The town is located along the Volta River, off of the Accra-Aflao motorway. Known for Palm tree, pal ...
). *
Floating point In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and soft ...
data types, usually represent values as high-precision fractional values (
rational numbers In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). ...
, mathematically), but are sometimes misleadingly called reals (evocative of mathematical
real numbers Real may refer to: * Reality, the state of things as they exist, rather than as they may appear or may be thought to be Currencies * Brazilian real (R\$) * Central American Republic real * Mexican real * Portuguese real * Spanish real * Spanish col ...

). They usually have predefined limits on both their maximum values and their precision. Typically stored internally in the form (where and are integers), but displayed in familiar
decimal The decimal numeral system A numeral system (or system of numeration) is a writing system A writing system is a method of visually representing verbal communication Communication (from Latin ''communicare'', meaning "to share") is t ...
form. * Fixed point data types are convenient for representing monetary values. They are often implemented internally as integers, leading to predefined limits. *
Bignum In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , , ...
or arbitrary precision numeric types lack predefined limits. They are not primitive types, and are used sparingly for efficiency reasons.

## Composite types

Composite type In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of comp ...
s are derived from more than one primitive type. This can be done in a number of ways. The ways they are combined are called
data structure In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of ...

s. Composing a primitive type into a compound type generally results in a new type, e.g. ''array-of-integer'' is a different type to ''integer''. * An
array ARRAY, also known as ARRAY Now, is an independent distribution company launched by film maker and former publicist Ava DuVernay Ava Marie DuVernay (; born August 24, 1972) is an American filmmaker. She won the directing award in the U.S. dram ...
(also called vector,
list A ''list'' is any set of items. List or lists may also refer to: People * List (surname)List or Liste is a European surname. Notable people with the surname include: List * Friedrich List (1789–1846), German economist * Garrett List (194 ...
, or sequence) stores a number of elements and provides
random access Random access (more precisely and more generally called direct access) is the ability to access an arbitrary element of a sequence in equal time or any datum from a population of addressable elements roughly as easily and efficiently as any othe ...
to individual elements. The elements of an array are typically (but not in all contexts) required to be of the same type. Arrays may be fixed-length or expandable. Indices into an array are typically required to be integers (if not, one may stress this relaxation by speaking about an
associative array In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , ...
) from a specific range (if not all indices in that range correspond to elements, it may be a
sparse array A sparse matrix obtained when solving a finite element problem in two dimensions. The non-zero elements are shown in black. In numerical analysis (c. 1800–1600 BC) with annotations. The approximation of the square root of 2 is four sexagesima ...
). * Record (also called tuple or struct) Records are among the simplest
data structure In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of ...

s. A record is a value that contains other values, typically in fixed number and sequence and typically indexed by names. The elements of records are usually called ''fields'' or ''members''. * Union. A union type definition will specify which of a number of permitted primitive types may be stored in its instances, e.g. "float or long integer". Contrast with a record, which could be defined to contain a float ''and'' an integer; whereas, in a union, there is only one type allowed at a time. ** A
tagged unionIn computer science, a tagged union, also called a variant type, variant, variant record, choice type, discriminated union, disjoint union, sum type or coproduct, is a data structure used to hold a value that could take on several different, but fixe ...
(also called a
variant Variant may refer to: In arts and entertainment *Variant (magazine), ''Variant'' (magazine), former British cultural magazine *Variant cover, of issue of comic books with varying cover art * Variant (novel), ''Variant'' (novel), by Robison Wells I ...
, variant record, discriminated union, or disjoint union) contains an additional field indicating its current type for enhanced type safety. * A set is an abstract data structure that can store certain values, without any particular
order Order, ORDER or Orders may refer to: * Orderliness Orderliness is a quality that is characterized by a person’s interest in keeping their surroundings and themselves well organized, and is associated with other qualities such as cleanliness a ...

, and no repeated values. Values themselves are not retrieved from sets, rather one tests a value for membership to obtain a boolean "in" or "not in". * An
object Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Entity, something that is tangible and within the grasp of the senses ** Object (abstract), an object which does not exist at any particular time or pl ...
contains a number of data fields, like a record, and also a number of subroutines for accessing or modifying them, called methods. Many others are possible, but they tend to be further variations and compounds of the above. For example, a
linked list In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , ...

can store the same data as an array, but provides
sequential access Sequential access is a term describing a group of elements (such as data in a memory array or a Hard disk drive, disk file or on magnetic tape data storage) being accessed in a predetermined, ordered sequence. It is the opposite of random access, t ...
rather than random and is built up of records in
dynamic memory Memory management is a form of Resource management (computing), resource management applied to computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their re ...
; though arguably a data structure rather than a type ''per se'', it is also common and distinct enough that including it in a discussion of composite types can be justified.

### String and text types

Such as: * A
character Character(s) may refer to: Arts, entertainment, and media Literature * ''Character'' (novel), a 1936 Dutch novel by Ferdinand Bordewijk * ''Characters'' (Theophrastus), a classical Greek set of character sketches attributed to Theophrastus M ...
, which may be a letter of some
alphabet An alphabet is a standardized set of basic written symbols A symbol is a mark, sign, or word In linguistics, a word of a spoken language can be defined as the smallest sequence of phonemes that can be uttered in isolation with semanti ...

, a digit, a blank space, a punctuation mark, etc. * A
string String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * Strings (1991 film), ''Strings'' (1991 fil ...
, which is a sequence of characters. Strings are typically used to represent words and text, although text in all but the most trivial cases involves much more than a sequence of characters. Character and string types can store sequences of characters from a character set such as
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding Character encoding is the process of assigning numbers to graphical Graphics (from Greek Greek may refer to: Greece Anything of, ...
. Since most character sets include the digits, it is possible to have a numeric string, such as `"1234"`. However, many languages treat these as belonging to a different type to the numeric value `1234`. Character and string types can have different subtypes according to the required character "width". The original 7-bit wide ASCII was found to be limited, and superseded by 8 and 16-bit sets, which can encode a wide variety of non-Latin alphabets (such as
Hebrew Hebrew (, , or ) is a Northwest Semitic languages, Northwest Semitic language of the Afroasiatic languages, Afroasiatic language family. Historically, it is regarded as one of the spoken languages of the Israelites and their longest-survivi ...
and
Chinese Chinese can refer to: * Something related to China China, officially the People's Republic of China (PRC), is a country in East Asia. It is the List of countries and dependencies by population, world's most populous country, with a populat ...
) and other symbols. Strings may be either stretch-to-fit or of fixed size, even in the same programming language. They may also be subtyped by their maximum size. Note: Strings are not a primitive data type in all languages. In C, for instance, they are composed from an array of characters.

## Abstract data types

Any data type that does not specify the concrete representation of the data is an
abstract data type In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , ...
. Instead, a formal ''specification'' based on the data type's operations is used to describe it. Any ''implementation'' of a specification must fulfill the rules given. Abstract data types are used in formal
semantics Semantics (from grc, σημαντικός ''sēmantikós'', "significant") is the study of reference Reference is a relationship between objects in which one object designates, or acts as a means by which to connect to or link to, another ...
and program verification and, less strictly, in
design A design is a plan or specification for the construction of an object or system or for the implementation of an activity or process, or the result of that plan or specification in the form of a prototype A prototype is an early sample, mode ...

. Beyond verification, a specification might immediately be turned into an implementation. The OBJ family of programming languages for instance bases on this option using
equation In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no ge ...

s for specification and
rewriting In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...
to run them.
Algebraic specification Algebraic specification is a software engineering technique for formally specifying system behavior. It was a very active subject of CS research around 1980. Overview Algebraic specification seeks to systematically develop more efficient programs ...
was an important subject of research in CS around 1980 and almost a synonym for abstract data types at that time. It has a mathematical foundation in
Universal algebra Universal algebra (sometimes called general algebra) is the field of mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spa ...
. The specification language can be made more expressive by allowing other formulas than only equations. A typical example is the Boom hierarchy of the
binary tree In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , ...

,
list A ''list'' is any set of items. List or lists may also refer to: People * List (surname)List or Liste is a European surname. Notable people with the surname include: List * Friedrich List (1789–1846), German economist * Garrett List (194 ...
,
bag A bag (also known regionally as a sack) is a common tool A tool is an object that can extend an individual's ability to modify features of the surrounding environment. Although many animals use simple tools, only human beings, whose use of ...
and set data types. All these data types can be declared by three operations: ''null'', which constructs the empty container, ''single'', which constructs a container from a single element and ''append'', which combines two containers of the same type. The complete specification for the four data types can then be given by successively adding the following rules over these operations: 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.

## Other types

Types can be based on, or derived from, the basic types explained above. In some languages, such as C,
function Function or functionality may refer to: Computing * Function key A function key is a key on a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...
s have a type derived from the type of their
return value In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, gener ...
.

### Pointers and references

The main non-composite, derived type is the pointer, a data type whose value refers directly to (or "points to") another value stored elsewhere in the
computer memory In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and soft ...
using its
address An address is a collection of information, presented in a mostly fixed format, used to give the location of a building, apartment, or other structure or a plot of land, generally using political boundaries Borders are geographic Geogr ...
. It is a primitive kind of
reference Reference is a relationship between objects in which one object designates, or acts as a means by which to connect to or link to, another object. The first object in this relation is said to ''refer to'' the second object. It is called a ''name ...
. (In everyday terms, a page number in a book could be considered a piece of data that refers to another one). Pointers are often stored in a format similar to an integer; however, attempting to dereference or "look up" a pointer whose value was never a valid memory address would cause a program to crash. To ameliorate this potential problem, pointers are considered a separate type to the type of data they point to, even if the underlying representation is the same.

### Function types

While functions can be assigned a type, too, their type is not considered a data type in the setting of this article. Here, data is viewed as being distinct from
algorithm In and , an algorithm () is a finite sequence of , computer-implementable instructions, typically to solve a class of problems or to perform a computation. Algorithms are always and are used as specifications for performing s, , , and other ...

s. In programming, functions are strongly related to the latter. But, because a central tenet of is that algorithms can be represented as data, e.g., textual description and binary programs, the contrast between data and functions has limits. In fact, not only can functions be represented by data, but functions can also be used to encode data. Many contemporary type systems focus strongly on function types and many modern languages allow functions to operate as first-class citizens. To exclude functions from the being treated as data types is not uncommon in related fields. Predicate logic for instance does not allow the application of Quantifier (logic), quantifiers on function or predicate names.

### Meta types

Some programming languages represent the type information as data, enabling type introspection and Reflection (computer programming), reflection. In contrast, Type constructor, higher order type systems, while allowing types to be constructed from other types and passed to functions as values, typically avoid basing computational decisions on them.

### Utility types

For convenience, high-level languages may supply ready-made "real world" data types, for instance ''times'', ''dates'', ''monetary values'', and ''memory'', even where the language would allow them to be built from primitive types.

# Type systems

A
type system In programming language A programming language is a formal language comprising a Instruction set architecture, set of instructions that produce various kinds of Input/output, output. Programming languages are used in computer programming to ...
associates types with computed values. By examining the flow of these values, a type system attempts to prove that no ''type errors'' can occur. The type system in question determines what constitutes a type error, but a type system generally seeks to guarantee that operations expecting a certain kind of value are not used with values for which that operation does not make sense. A
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily ...

may use the static type of a value to optimize the storage it needs and the choice of algorithms for operations on the value. In many C compilers the data type, for example, is represented in 32
bit The bit is a basic unit of information in computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithm of an algorithm (Euclid's algo ...
s, in accord with the IEEE 754-2008, IEEE specification for single-precision floating point numbers. They will thus use floating-point-specific instruction set, microprocessor operations on those values (floating-point addition, multiplication, etc.). The depth of type constraints and the manner of their evaluation affect the ''typing'' of the language. A programming language may further associate an operation with varying concrete algorithms on each type in the case of type polymorphism. Type theory is the study of type systems, although the concrete type systems of programming languages originate from practical issues of computer architecture, compiler implementation, and language design. Type systems may be variously static typing, static or dynamic typing, dynamic, strong typing, strong or weak typing, and so forth.