Talk:Zero-based numbering

Talk:Zero-based numbering

BCPL anecdote

I find the BCPL anecdote misleading, not only have I have multiple multiple different versions of it, but it misquotes both Hoye and Stevens. The bit about the 7094 was not something Stevens said, it was Mike's speculation based on a separate document, and the indirection operation in BCPL was always at run-time because it was completely beyond the state of the art in compiler technology in the early '60s to track which words used in indirection were safe to optimize in the way he suggests.

BCPL arrays were zero-origin because it fell naturally out of the unification of pointers and other values in a low level language. Stevens says as much in the comment Mike quotes:

As for BCPL and C subscripts starting at zero. BCPL was essentially designed as typeless language close to machine code. Just as in machine code registers are typically all the same size and contain values that represent almost anything, such as integers, machine addresses, truth values, characters, etc. BCPL has typeless variables just like machine registers capable of representing anything. If a BCPL variable represents a pointer, it points to one or more consecutive words of memory. These words are the same size as BCPL variables. Just as machine code allows address arithmetic so does BCPL, so if p is a pointer p+1 is a pointer to the next word after the one p points to. Naturally p+0 has the same value as p. The monodic indirection operator ! takes a pointer as it’s argument and returns the contents of the word pointed to. If v is a pointer !(v+I) will access the word pointed to by v+I. As I varies from zero upwards we access consecutive locations starting at the one pointed to by v when I is zero. The dyadic version of ! is defined so that v!i = !(v+I). v!i behaves like a subscripted expression with v being a one dimensional array and I being an integer subscript. It is entirely natural for the first element of the array to have subscript zero. C copied BCPL’s approach using * for monodic ! and [ ] for array subscription. Note that, in BCPL v!5 = !(v+5) = !(5+v) = 5!v. The same happens in C, v[5] = 5[v]. I can see no sensible reason why the first element of a BCPL array should have subscript one. Note that 5!v is rather like a field selector accessing a field in a structure pointed to by v.

— Richard Stephens

But the speculation about performance considerations on the 7094, and especially the idea that it was precalculating indirection at compile time, are not supported by the original documentation. When you allocate a vector in BCPL, like "LET V = VEC 5", you actually allocated 6 words, the first of which contained the address of the second. Most if not all of the time you *created* it on the stack, at runtime. You could freely initialize words with addresses calculated at runtime, such as this example taken from the BCPL manual:

LET IOV = VEC 650
LET IOVP, IOVT = IOV, IOV + 650

The basic premise is already fubar-level flawed

quote

With zero-based numbering, a range can be expressed as the half-open interval, [0, n), as opposed to the closed interval, [1, n].

Who says 1-based numbering couldn't use the half-open interval of (0, n] ??? How is [0, n) any superior compared to (0, n] ??? 2603:7000:3C3D:4840:0:0:0:1D7 (talk) 07:33, 20 June 2025 (UTC)Reply

The second paragraph of § Origins is reporting what Dijkstra wrote, not agreeing with him. I happen to think that it's nonsense, and the mathematical literature still mostly uses 1-base section numbers and indices,[a] but it matches my recollection of what he wrote. -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 13:01, 20 June 2025 (UTC)Reply

Notes

  1. ^ But physics literature often uses 0 for a time-like index.

natural number

How is one integer more natural than another? The article Natural number says not everyone agrees on including zero, so how is zero "the most natural number"? —Tamfang (talk) 21:19, 1 October 2025 (UTC)Reply

Mathematics is full of terms of art that should not be confused with the common English meanings of the word; there is nothing complicated about complex numbers, imaginary numbers have as much or as little existence as other numbers, there is nothing unreasonable about irrational numbers and there is nothing lofty about transcendental numbers. So the technical meaning of natural number is how it is used in the mathematical literature. See Natural number § Emergence as a term for a discussion of which usage dominates in which field. In the text In 1982 Edsger W. Dijkstra in his pertinent note Why numbering should start at zero[1] argued that arrays subscripts should start at zero as that's the most natural number., what matters is which usage Dijkstra used, and any reference to the quote should be consistent with his zero as a most natural number.
BTW, I don't agree with him, but that has no relevance in this context. -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 12:49, 3 October 2025 (UTC)Reply
Dijkstra argued that zero is most natural for this purpose, which is only tenuously related to any definition of the natural numbers; that is why I tried to change the wording, and remove the link. Did Dijkstra say that zero is the most natural of the natural numbers? —Tamfang (talk) 02:41, 4 October 2025 (UTC)Reply
He started with To denote the subsequence of natural numbers 2, 3, ..., 12 without the pernicious three dots, so, yes, he does refer to natural numbers, although later he refers specifically to ordinals. -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 13:14, 4 October 2025 (UTC)Reply
Okay, reading the quotation, I think we ought to read most here as fully rather than uniquely; and the sentence as tangential. He's not saying that zero is the most natural of the integers and therefore ought to be used in indexing; he's saying that the clear usefulness of considering zero as one of the naturals makes it perverse not to. —Tamfang (talk) 04:17, 5 October 2025 (UTC)Reply
Yeah .... "so natural" of a number zero that :
(1) It's the only natural number that cannot act as a base to describe larger numbers (Base 1 would just be number of copies).
(2) It's the only natural number that doesn't yield a finite value from its logarithm.
(3) It's the only integer that you can raise to another finite integer power and end up with infinity.
(4) It's the only divisor that is undefinable in Euclidean Division.
(5) It's the only natural number under 4000 that has no representation by Roman Numerals.
(6) It's the only value on the Kelvins temperature scale that is never measurable.
(7) It's the only exponent that you can raise from a transcendental base and end up with a rational.
Most natural indeed. ~2026-18096-35 (talk) 01:43, 23 March 2026 (UTC)Reply
(3) It's the only integer that you can raise to another finite integer power and end up with infinity.
Not quite; and in , i.e., , or although it has a useful meaning in the one point compactification -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 08:33, 23 March 2026 (UTC)Reply
i said the exponent is another finite integer and somehow you completely misrepresented my statement and talked about Real numbers with and without the union with infinities. ~2026-32914-27 (talk) 08:21, 3 June 2026 (UTC)Reply
and I dunno what you're talking about being undefined in reals.
2-epi ~ 1.0813278712707951382613699 × 10-7
https://www.wolframalpha.com/input?i=2%5E-exp%28pi%29
Even 2 to a negated transcendental exponent is well defined. ~2026-32914-27 (talk) 08:31, 3 June 2026 (UTC)Reply
Typo corrected. what's the equivalent of <del>...</del> and <ins>...</ins> in LaTeX? -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 13:11, 3 June 2026 (UTC)Reply

References

  1. ^ Dijkstra, Edsger Wybe (May 2, 2008). "Why numbering should start at zero (EWD 831)". E. W. Dijkstra Archive. University of Texas at Austin. Retrieved 2011-03-16. When dealing with a sequence of length N, the elements of which we wish to distinguish by subscript, the next vexing question is what subscript value to assign to its starting element. Adhering to convention a) yields, when starting with subscript 1, the subscript range 1 ≤ i < N+1; starting with 0, however, gives the nicer range 0 ≤ i < N. So let us let our ordinals start at zero: an element's ordinal (subscript) equals the number of elements preceding it in the sequence. And the moral of the story is that we had better regard —after all those centuries!— zero as a most natural number.

Use in mathematics

The lead states Numbering sequences starting at 0 is quite common in mathematics notation,, but the norm is to number sequences starting at 1, combinatorics notwithstanding. The major exception is transfinite induction, where the indexing ordinals normally start at . -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:32, 3 July 2026 (UTC)Reply

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.