Content deleted Content added
Add missing comma |
m Disambiguated |
||
Line 1:
{{Refimprove|date=March 2010}}
'''Zero-based numbering''' is numbering in which the initial element of a sequence is assigned the index 0, rather than the index 1 as is typical in everyday circumstances. Under zero-based numbering, the initial element is sometimes termed the [[
Numbering sequences starting at 0 is quite common in mathematics, in particular in [[combinatorics]]. In [[computer science]], [[Array data structure|array]] indices also often start at 0, so computer programmers might use ''zeroth'' in situations where others might use ''first'', and so forth. In some mathematical contexts, zero-based numbering can be used without confusion, when ordinal forms have well established meaning with an obvious candidate to come before ''first''; for instance a ''zeroth derivative'' of a function is the function itself, obtained by [[derivative|differentiating]] zero times. Such usage corresponds to naming an element not properly belonging to the sequence but preceding it: the zeroth derivative is not really a derivative at all. However, just as the ''first derivative'' precedes the ''second derivative'', so also does the ''zeroth derivative'' (or the original function itself) precede the ''first derivative''.
Line 40:
A third property is that a range is more elegantly expressed as the half-open [[Interval (mathematics)|interval]], [0,''n''), as opposed to the closed interval, [1,''n'']. Empty ranges, which often occur in algorithms, are tricky to express with a closed interval without resorting to obtuse conventions like [1,0]. This half-open convention may avoid [[off-by-one error]]s or [[fencepost error]]s. On the other hand, often the repeat count ''n'' is calculated in advance, making the use of counting from 0 to ''n''−1 (inclusive) less intuitive.
This situation can lead to some confusion in terminology. In a zero-based indexing scheme, the first element is "element number zero"; likewise, the twelfth element is "element number eleven". Therefore, an analogy from the ordinal numbers to the quantity of objects numbered appears; the highest index of ''n'' objects will be {{nowrap|''n'' − 1}} and referred to the ''n''th element. For this reason, the first element is often referred to as the ''
===Disadvantages===
|