Range (computer programming): Difference between revisions

Content deleted Content added
LucienBOT (talk | contribs)
m robot Adding: es:Rango (informática)
m clean up using AWB
Line 1:
{{Unreferenced|date=December 2006}}
In [[computer science]], the term '''range''' may refer to one of two things:
# The maximum and minimum values that may be stored in a [[variable (programming)|variable]].
# The upper and lower bounds of an [[array]].
 
== 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 [[signedness|signed]] [[16-bit]] [[Integer (computer science)|integer]] 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 point]] 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 ==
{{mainMain|Array#Indexing}}
 
When an array is numerically [[Index (information technology)|indexed]], 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 languages, such as [[C (programming language)|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).
 
==See also==
 
[[Interval (mathematics)|Interval]]
 
{{DEFAULTSORT:Range (Computer Science)}}
[[Category:Programming constructs]]
[[Category:Arrays]]
[[Category:Articles lacking sources (Erik9bot)]]
 
 
{{compuCompu-prog-stub}}
 
[[es:Rango (informática)]]