related topics
{math, number, function}
{system, computer, user}
{theory, work, human}
{day, year, event}
{work, book, publish}
{school, student, university}
{law, state, case}
{build, building, house}
{album, band, music}
{service, military, aircraft}
{math, energy, light}

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 often termed the "zeroth" element, rather than the first element; "zeroth" is a coined ordinal number corresponding to the number zero. In some cases, an object or value that does not (originally) belong to a given sequence, but which could be naturally placed before its initial element, may be termed the zeroth element. The correctness of using zero as an ordinal is not universally agreed upon as it creates ambiguity for all subsequent elements of the sequence when lacking context.

Numbering sequences starting at 0 is quite common in mathematics, in particular in combinatorics. In computer science, 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 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.


In computer programming

This usage follows from design choices embedded in many influential programming languages, including C, Java, and Lisp. In these three, sequence types (C arrays, Java arrays and lists, and Lisp lists and vectors) are indexed beginning with the zero subscript. Particularly in C, where arrays are closely tied to pointer arithmetic, this makes for a simpler implementation: the subscript refers to an offset from the starting position of an array, so the first element has an offset of zero.

Referencing memory by an address and an offset is represented directly in hardware on virtually all computer architectures, so this design detail in C makes compilation easier and run times faster, at the cost of some human factors. In this context using "zeroth" as an ordinal is not strictly correct, but professional shorthand. Older programming languages, such as Fortran or Cobol have array subscripts starting with one, because they were meant as high-level programming languages, and as such they had to have a correspondence to the usual ordinal numbers. Some recent languages, such as Lua, have adopted the same convention for the same reason.

Zero is the lowest unsigned integer value, one of the most fundamental types in programming and hardware design. In computer science, zero is thus often used as the base case for many kinds of numerical recursion. Proofs and other sorts of mathematical reasoning in computer science often begin with zero. For these reasons, in computer science it is not unusual to number from zero rather than one.

Full article ▸

related documents
Dublin Core
GNU Octave
Code refactoring
Atlas Autocode
Search engine (computing)
Range encoding
Category (mathematics)
Syntactic sugar
Absolute Infinite
Magma computer algebra system
Hash collision
Borel-Cantelli lemma
Double negative elimination
Nowhere dense set
Weierstrass–Casorati theorem
Dyadic rational
Stirling number
Algebraic number
T1 space
Cayley's theorem
Malleability (cryptography)
Partial function
Calculus with polynomials
Regular space
Real line
MOO (programming language)
Alternative algebra