| Posted in Data (computing) | Posted on 21:28
Data (computing)
In computer science, data is anything in a form suitable for use with a computer.Data is often distinguished from programs. A program is a set of instructions that detail a task for the computer to perform. In this sense, data is thus everything that is not program code.
In an alternate usage, binary files (which are not human-readable) are sometimes called "data" as distinguished from human-readable "text".The total amount of digital data in 2007 was estimated to be 281 billiongigabytes.
Data vs programs
Fundamentally, computers follow the instructions they are given. A set of instructions to perform a given task (or tasks) is called a "program". In the nominal case, the program, as executed by the computer, will consist ofbinary machine code. The elements of storage manipulated by the program, but not actually executed by theCPU, contain data.
Typically, different files are used to store programs vs data. Executable files contain programs; all other files aredata files. However, executable files may also contain data which is "built-in" to the program. In particular, some executable files have a data segment, which nominally contains constants and initial values (both data).
For example: a user might first instruct the operating system to load a word processor program from one file, and then edit a document stored in another file. In this example, the document would be considered data. If the word processor also features a spell checker, then the dictionary (word list) for the spell checker would also be considered data. The algorithms used by the spell checker to suggest corrections would be considered code.
The line between program and data can become blurry. An interpreter, for example, is a program. The input data to an interpreter is itself a program—just not one expressed in native machine language. In many cases, the interpreted program will be a human-readable text file, which is manipulated with a text editor—more normally associated with plain text data.
A data segment is one of the sections of a program in an object file or in memory, which contains the global variables and static variables that are initialized by the programmer. It has a fixed size, since all of the data in this section is set by the programmer before the program is loaded. However, it is not read-only, since the values of the variables can be altered at runtime. This is in contrast to the Rodata (constant, read-only data) section, as well as the code segment (also known as text segment).
In the PC architecture there are four basic read-write memory regions in a program: Stack, Data, BSS, and Heap. Sometimes the data, BSS, and heap areas are collectively referred to as the "data segment".
To resume, RAM area contains:
- Data Segment (Data + BSS + Heap)
- Stack
In detail:
- The Data area contains global and static variables used by the program that are not initialized to zero. This segment can be further classified into initialized read-only area and initialized read-write area. For instance the string defined by
char s[] = "hello world";in C and a C statement likeint debug=1;outside the main would be stored in initialized read-write area. And a C statement likechar *string = "hello world";makes the string literal"hello world"to be stored in initialized read-only area and the character pointer variablestringin initialized read-write area. - The BSS segment also known as Uninitialized data starts at the end of the data segment and contains all global and static variables that are initialized to zero by default. For instance a variable declared
static int i;would be contained in the BSS segment. - The heap area begins at the end of the BSS segment and grows to larger addresses from there. The Heap area is managed by malloc, realloc, and free, which may use the brk and sbrk system calls to adjust its size (although, note that the use of brk/sbrk and a single "heap area" is not required to fulfil the contract of malloc/realloc/free; they may also be implemented using mmap to reserve potentially non-contiguous regions of virtual memory into the process' virtual address space). The Heap area is shared by all shared libraries and dynamically loaded modules in a process.
- The stack is a LIFO structure, typically located in the higher parts of memory. It usually "grows down" with every register, immediate value or stack frame being added to it. A stack frame consists at minimum of a return address.
- A data type (or datatype) In programming, a classification identifying one of various types of data, as floating-point, integer, or Boolean, stating the possible values for that type, the operations that can be done on that type, and the way the values of that type are stored.
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,
- floating-point numbers (decimals), and
- alphanumeric strings.
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 bytes 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 also represents a constraint placed upon the interpretation of data in a type system, describing representation, interpretation and structure of values 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.
All data in computers based on digital electronics is represented as bits (alternatives 0 and 1) on the lowest level. The smallest addressable unit of data is usually a group of bits called a byte (usually an octet, which is 8 bits). The unit processed by machine code instructions is called a word (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 232 − 1 or signed integer values from − 231 to 231 − 1. Because of two's complement, 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. l