In
computer scienceComputer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems. It is frequently described as the systematic study of algorithmic processes that create, describe and transform...
, the term
range may refer to one of two things:
- The maximum and minimum values that may be stored in a variable
In computer programming, a variable is a facility for storing data. The current value of the variable is the data actually stored in the variable. Depending on the programming language in question, the data stored in the variable can be intentionally altered during the program run. This is why it...
.
- The upper and lower bounds of an array
In computer science, an array data structure or simply array is a data structure consisting of a collection of elements , each identified by one or more integer indices, stored so that the address of each element can be computed from its index tuple by a simple mathematical formula...
.
The range of a variable is given as the difference between the highest and lowest value that that variable can hold. For example,
the range of a
signedIn computing, signedness is a property of variables 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 positive numbers....
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...
integerIn 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.- Value and representation :...
variable is -32,768 to +32,767.
In
computer scienceComputer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems. It is frequently described as the systematic study of algorithmic processes that create, describe and transform...
, the term
range may refer to one of two things:
- The maximum and minimum values that may be stored in a variable
In computer programming, a variable is a facility for storing data. The current value of the variable is the data actually stored in the variable. Depending on the programming language in question, the data stored in the variable can be intentionally altered during the program run. This is why it...
.
- The upper and lower bounds of an array
In computer science, an array data structure or simply array is a data structure consisting of a collection of elements , each identified by one or more integer indices, stored so that the address of each element can be computed from its index tuple by a simple mathematical formula...
.
Range of a variable
The range of a variable is given as the difference between the highest and lowest value that that variable can hold. For example,
the range of a
signedIn computing, signedness is a property of variables 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 positive numbers....
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...
integerIn 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.- Value and representation :...
variable is -32,768 to +32,767. 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). However, for other numeric types, such as
floating pointIn computing, floating point describes a system for numerical representation in which a string of digits represents a rational number....
numbers, the range only expresses the largest and smallest number that may be stored - within the range there will be many numbers that cannot be represented.
Range of an array
When an array is numerically
indexedIn computer science, an index can be:# an integer which 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 errorIn computing, a fatal error is an error which causes a program to abort - and thus may return the user to the operating system. When this happens, data that the program was processing may be lost...
, or unpredictable behavior will occur if the program attempts to access an array element that is outside the range. In some languages, such as
CC is a general-purpose computer programming language developed in 1972 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
PHPPHP, or PHP: Hypertext Preprocessor, is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web...
, 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).