![](http://image.absoluteastronomy.com/images//topicimages/noimage.gif)
Range (computer science)
Encyclopedia
In computer science
, the term range may refer to one of three things:
16-bit
integer
variable is all the integers from −32,768 to +32,767.
, its range is the upper and lower bound of the array. Depending on the environment, a warning, a fatal error
, or unpredictable behavior will occur if the program attempts to access an array element that is outside the range. In some programming languages, such as C
, arrays have a fixed lower bound (zero) and will contain data at each position up to the upper bound (so an array with 5 elements will have a range of 0 to 4). In others, such as PHP
, an array may have holes where no element is defined, and therefore an array with a range of 0 to 4 will have up to 5 elements (and a minimum of 2).
. When used in this sense, range is defined as "a pair of begin/end iterators packed together" . It is argued that "Ranges are a superior abstraction" (compared to iterators) for several reasons, including better safety.
In particular, such ranges are supported in Boost C++ Libraries .
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...
, the term range may refer to one of three things:
- The possible values that may be stored in a variableVariable (programming)In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...
. - The upper and lower bounds of an array.
- An alternative to iteratorIteratorIn computer programming, an iterator is an object that enables a programmer to traverse a container. Various types of iterators are often provided via a container's interface...
.
Range of a variable
The range of a variable is given as the set of possible values that that variable can hold. In the case of an integer, the variable definition is restricted to whole numbers only, and the range will cover every number within its range (including the maximum and minimum). For example, the range of a signedSignedness
In computing, signedness is a property of data types representing numbers in computer programs. A numeric variable is signed if it can represent both positive and negative numbers, and unsigned if it can only represent non-negative numbers .As signed numbers can represent negative numbers, they...
16-bit
16-bit
-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...
integer
Integer (computer science)
In computer science, an integer is a datum of integral data type, a data type which represents some finite subset of the mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values....
variable is all the integers from −32,768 to +32,767.
Range of an array
When an array is numerically indexedIndex (information technology)
In computer science, an index can be:# an integer that identifies an array element# a data structure that enables sublinear-time lookup -Array element identifier:...
, its range is the upper and lower bound of the array. Depending on the environment, a warning, a fatal error
Fatal error
In computing, a fatal error or fatal exception error is an error that causes a program to abort and may therefore return the user to the operating system. When this happens, data that the program was processing may be lost. A fatal error is usually distinguished from a fatal system error...
, or unpredictable behavior will occur if the program attempts to access an array element that is outside the range. In some programming languages, such as C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
, arrays have a fixed lower bound (zero) and will contain data at each position up to the upper bound (so an array with 5 elements will have a range of 0 to 4). In others, such as PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...
, an array may have holes where no element is defined, and therefore an array with a range of 0 to 4 will have up to 5 elements (and a minimum of 2).
Range as an alternative to iterator
Another meaning of range in computer science is an alternative to iteratorIterator
In computer programming, an iterator is an object that enables a programmer to traverse a container. Various types of iterators are often provided via a container's interface...
. When used in this sense, range is defined as "a pair of begin/end iterators packed together" . It is argued that "Ranges are a superior abstraction" (compared to iterators) for several reasons, including better safety.
In particular, such ranges are supported in Boost C++ Libraries .