All Topics  
Data type

 

   Email Print
   Bookmark   Link






 

Data type



 
 
A data type in programming languages is an attribute of a data
DATA

Debt, AIDS, Trade in Africa is a multinational Non-governmental organization founded in January 2002 in London by U2's Bono along with Robert Sargent Shriver III and activists from the Jubilee 2000 Drop the Debt campaign....
 which tells the computer (and the programmer) something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it.

broad sense, a data type defines a set of values and the allowable operations on those values.






Discussion
Ask a question about 'Data type'
Start a new discussion about 'Data type'
Answer questions from other users
Full Discussion Forum



Encyclopedia


A data type in programming languages is an attribute of a data
DATA

Debt, AIDS, Trade in Africa is a multinational Non-governmental organization founded in January 2002 in London by U2's Bono along with Robert Sargent Shriver III and activists from the Jubilee 2000 Drop the Debt campaign....
 which tells the computer (and the programmer) something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it.

Overview

In a broad sense, a data type defines a set of values and the allowable operations on those values. Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. 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 "Person" that specifies that data interpreted as Person would include a name and a date of birth. Common data types may include:
  • integers
    Integer (computer science)

    In computer science, the term integer is used to refer to a data type which represents some finite subset of the mathematical integers. These are also known as integral data types....
    ,
  • floating-point
    Floating point

    In computing, floating point describes a system for numerical representation in which a String of digits represents a rational number.The term floating point refers to the fact that the radix point can "float": that is, it can be placed anywhere relative to the Significant figures of the number....
     numbers (decimals), and
  • alphanumeric strings
    String (computer science)

    In computer programming and some branches of mathematics, a string is an ordered sequence of symbols. These symbols are chosen from a predetermined set or alphabet....
    .
For example, in the Java programming language
Java (programming language)

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java ....
, the "int" type represents the set of 32-bit
32-bit

The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295 or -2,147,483,648 through 2,147,483,647 using two's complement encoding....
 integers
Integer (computer science)

In computer science, the term integer is used to refer to a data type which represents some finite subset of the mathematical integers. These are also known as integral data types....
 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 byte
Byte

A byte is a basic unit of measurement of Computer storage in computer science. In many computer architectures it is a Byte addressing memory address space....
s denoting 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.

A data type can also be thought of as a constraint placed upon the interpretation of data in a type system
Type system

In computer science, a type system may be defined as "a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute."....
, describing representation, interpretation and structure of value
Value (computer science)

In computer science, a value is a sequence of bits that is interpreted according to some data type. It is possible for the same sequence of bits to have different values, depending on the type used to interpret its meaning....
s or object
Object (computer science)

In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variable#Computer_programmings to access objects, the terms object and variable are often used interchangeably....
s stored in computer memory. The type system uses data type information to check correctness
Correctness

In theoretical computer science, correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a program specification....
 of computer programs that access or manipulate the data.

Types of data types


Abstract data types (ADT )


Algebraic types


Composite types


Function types


Machine data types

All data in computers based on digital electronics is represented as bit
Bit

A bit is a binary numeral system numerical digit, taking a value of either 0 or 1. Binary digits are a basic unit of information Computer data storage and transmission in digital computing and digital information theory....
s (alternatives 0 and 1) on the lowest level. The smallest addressable unit of data is a group of bits called a byte
Byte

A byte is a basic unit of measurement of Computer storage in computer science. In many computer architectures it is a Byte addressing memory address space....
 (usually an octet
Octet (computing)

In computing, an octet is a grouping of eight bits.Octet, with the only exception noted below, always refers to an entity having exactly eight bits....
, which is 8 bits). The unit processed by machine code
Machine code

Machine code or machine language is a system of instructions and data executed directly by a computer's central processing unit. Machine code may be regarded as a primitive programming language or as the lowest-level representation of a compiled and/or assembly language computer program....
 instructions is called a word
Word (computer science)

In computing, "word" is a term for the natural unit of data used by a particular computer design. A word is simply a fixed-sized group of bits that are handled together by the machine....
 (as of 2008, typically 32 or 64 bits). Most instructions interpret the word as a binary number, such that a 32-bit word can represent unsigned integer values from 0 to or signed integer values from to . Because of two's complement
Two's complement

The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of two .A two's-complement system or two's-complement arithmetic is a system in which negative numbers are represented by the two's complement of the absolute value; this system is the most common Signed number r...
, the machine language and machine don't need to distinguish between these unsigned and signed data types for the most part.

There is a specific set of arithmetic instructions that use a different interpretation of the bits in word as a floating-point number.

Object types


Pointer and reference types


Primitive types


See also


  • Data dictionary
    Data dictionary

    A data dictionary, as defined in the IBM Dictionary of Computing, is a "centralized repository of information about data such as meaning, relationships to other data, origin, usage, and format." The term may have one of several closely related meanings pertaining to databases and Database management system:...
  • Type theory
    Type theory

    In mathematics, logic and computer science, type theory is any of several formal systems that can serve as alternatives to naive set theory, or the study of such formalisms in general....
     for the mathematical models of types
  • Type system
    Type system

    In computer science, a type system may be defined as "a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute."....
     for different choices in programming language typing
  • Kind
    Kind (type theory)

    In computer science and type theory, a kind is a "type of a type". Kinds appear, either explicitly or implicitly, in certain languages with complex type systems, such as Haskell and Scala ....
    , a type of a type


Further reading

  • Luca Cardelli, Peter Wegner. On Understanding Types, Data Abstraction, and Polymorphism, from Computing Surveys, (December, 1985)