Data Type describes how data should be represented, interpreted and how the values should be structured or how objects are stored in the memory of the computer. It refers to the form of a data value and constraints placed on data interpretation, The form of data value vary and can take different forms such as date, number, string, float, packed, and double precision.
The type system uses data type information so that it could check for correctness of the computer programs which try to access or manipulate the data.
If one thinks of a computer in a physical perspective, the data storage system which is comprised mainly of the hard disk and the random access memory (RAM), all data are actually stored as a single bit on the surface of these storage areas. Data are stored based on digital electronics is represented as bits (alternatives 0 and 1) on the lowest level. This system is called the binary system. On the surface, it is just a simple indicator to say on or off.
A group of eight of these "on or off or 0 or 1" is called a byte and is the smallest addressable unit on the storage device. A "word" is the unit processed by machine code and is typically composed of 32 or 64 bits. The binary system can represent both signed and unsigned integer values (representing negative or positive values).
For instance, a 32-bit word can be used to represent unsigned integer values from 0 to 232 − 1 or signed integer values from − 231 to 231 − 1. A specific set of arithmetic instructions is used for interpreting a different kind of data type called a floating-point number.
Different language may give different representation of the same data type. For example, an integer may have a slight range difference in C language compared to Visual Basic. In another instance, a string data type may have different number of range between Access and Oracle relational databases.
This is just for the sake of example and the name mentioned may not be the exact applications having different data type interpretation but this is a common occurrence in information systems. But this does not erase the essence of the data type. For this purpose, we will describe below the primitive data types.
The primitive data types are as follows:
Integer data types – An integer can hold a whole number but not fractions. It can also hold negative values as signed integer. A signed integer holds only non-negative values. The typical sizes of integers are:
- Byte (composed of 8 bits with a range of -128 to +127 or signed and 0 to 255 for unsigned)
- Word or short int, composed of 16 bits with a range of -32,768 to +32,767 or signed and 0 to 65,535 for unsigned)
- Double Word or long int (composed of 32 bits with a range of -2,147,483,648 to +2,147,483,647 or signed and 0 to 4,294,967,295)
- Long (composed of 64 bits with a range of –9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 and 0 to 18,446,744,073,709,551,615 for unsigned).
Booleans – Are data types composed of one bit only to signify true (1) or false (0).
Floating-point – This data type represents a real number which may contain a fractional part. They are internally stored in scientific notations.
Characters and strings – A character is typically denoted as "char" and can contain a single letter, digit, punctuation mark, or control character. A group of characters are called a string.
Many other data types such as composite, abstract and pointer data types but they are very specific to the implementing software.