{
  "id": "enwiki-001378235475",
  "slug": "zero-based-numbering",
  "title": "Zero-based numbering",
  "qid": "",
  "lead": "Zero-based numbering is a way of numbering in which the initial element of a sequence is assigned the index 0, rather than the index 1 as is typical in everyday non-mathematical or non-programming circumstances. Under zero-based numbering, the initial element is sometimes termed the zeroth element, rather than the first element; zeroth is a coined word for the ordinal 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. There is no wide agreement regarding the correctness of using zero as an ordinal (nor regarding the use of the term zeroth), as it creates ambiguity for all subsequent elements of the sequence when lacking context. Numbering sequences starting at 0 is quite common in mathematics notation, in particular in combinatorics, though programming languages for mathematics usually index from 1. In computer science, array indices usually start at 0 in modern programming languages, so computer programmers might use zeroth in situations where others might use first, and so forth.…",
  "body": "Zero-based numbering is a way of numbering in which the initial element of a sequence is assigned the index&nbsp;0, rather than the index&nbsp;1 as is typical in everyday non-mathematical or non-programming circumstances. Under zero-based numbering, the initial element is sometimes termed the zeroth element, rather than the first element; zeroth is a coined word for the ordinal 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. There is no wide agreement regarding the correctness of using zero as an ordinal (nor regarding the use of the term zeroth), as it creates ambiguity for all subsequent elements of the sequence when lacking context. Numbering sequences starting at 0 is quite common in mathematics notation, in particular in combinatorics, though programming languages for mathematics usually index from&nbsp;1. In computer science, array indices usually start at 0 in modern programming languages, 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. 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. == Computer programming == === Usage in programming languages === 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 computer hardware on virtually all computer architectures, so this design detail in C makes compilation easier, at the cost of some human factors. In this context using \"zeroth\" as an ordinal is not strictly correct, but a widespread habit in this profession. Some 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 which predate the invention of the zero by a long time. And some programming languages, e.g., Ada, ALGOL 60, PL/I, allow an arbitrary lower bound for each index. Pascal allows the range of an array to be of any ordinal type (including enumerated types) and Ada allows any discrete subtype. APL allows setting the index origin to 0 or 1 during runtime programmatically. Some more recent languages, such as Lua and Visual Basic, 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. If an array is used to represent a cycle, it is convenient to obtain the index with a modulo function, which can result in zero. r = z \\cdot M \\cdot N + y \\cdot M + x. Organizing all arrays with 1-based indices ( , , , ), and assuming an analogous arrangement of the elements, gives r' = (z'-1) \\cdot M \\cdot N + (y'-1) \\cdot M + (x'-0) to access the same element, which arguably looks more complicated. Of course, since and A simple and everyday-life example is positional notation, which the invention of the zero made possible. In positional notation, tens, hundreds, thousands and all other digits start with zero, only units start at one. &emsp; 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 objects will be , and it refers to the th element. For this reason, the first element is sometimes referred to as the zeroth element, in an attempt to avoid confusion.",
  "categories": [
    "129550593",
    "20477108",
    "22904282",
    "23118434",
    "23603337",
    "24745113",
    "25029841",
    "55739791",
    "63715446",
    "68328988"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1378235475",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1791038767.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "enwiki-001378235475",
    "type": "webpage",
    "title": "Zero-based numbering",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/zero-based-numbering",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          20
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          20
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001378235475",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1378235475",
    "note": "Immutable snapshot enwiki-001378235475"
  }
}