Live data from Hacker News

Numbering should start at zero (1982)

cs.utexas.edu

231–240 of 309 posts

Re: Numbering should start at zero (1982)

#231

Numbering should start at π (2025) (umars.edu) Seriously, it all depends on whether u're counting the items themselves (1-based) or the spaces btwn them (0-based). The former uses natural numbers, while the latter uses non-negative integers For instance, when dealing with memory words, do u address the word itself or its starting location (the first byte)? The same consideration applies to coordinate systems: r u pos…

Actually, the duality arises from counting (there can be 0 items) and ordering (there is only a 1st item), conceptually. Which is why the year 2000 can and cannot be the start of the 3rd millenium, for instance.

Re: Numbering should start at zero (1982)

#232

Perhaps ideally we'd change English to count the "first" entry in a sequence as the "zeroth" item, but the path dependency and the effort required to do that is rather large to say the least. At least we're not stuck with the Roman "inclusive counting" system that included one extra number in ranges* so that e.g. weeks have "8" days and Sunday is two days before Monday since Monday is itself included in the count. *…

> At least we're not stuck with the Roman "inclusive counting" system that included one extra number in ranges* so that e.g. weeks have "8" days and Sunday is two days before Monday since Monday is itself included in the count. Yes, we are. C gives pointers one past the end of an array meaningful semantics. That's in the standard. You can compare them and operate on them but not de-reference them. Amusingly, you're n…

> C gives pointers one past the end of an array meaningful semantics

Nelson Elhage wrote about an alternate interpretation: https://blog.nelhage.com/2015/08/indices-point-between-eleme...

Re: Numbering should start at zero (1982)

#233

Earlier quoted context omitted.

Indexing is not really math, it's a reference-system which is using numbers for convenience. You could use letters or even emojis to get the same result.

[closed, open) intervals on the number line are well-known in math, as are operations on them. -0 is not, nor supported by hardware.

Yes, but Python is not math. This is a syntax-feature we are talking about, math is here just a tool, not the purpose. And it's also not running on hardware, but multiple layers higher.

Re: Numbering should start at zero (1982)

#234

I like my numbering to start like my tape measure: at zero.

Array elements are not a continuous measure. Level of water, for example, is.

The mark on your measure tape corresponds to the total sum/amount.

If you count from zero, number of elements no longer corresponds to the size/length. So already here you deviate away from your tape principle.

You have one whole element when your tape measure shows 1, not zero.

Re: Numbering should start at zero (1982)

#235
post #192

Earlier quoted context omitted.

IMO zero represents an absence of quantity and doesn't appear in Nature, so it cannot be classified as a Natural number Just like a negative numbers, it's a higher-level abstraction or a model, not a direct observation from the Nature Likewise, the digit "0" originating from the Hindu-Arabic numeral system[1] is merely a notation, not a number --- 1. https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_s...

> zero represents an absence of quantity and doesn't appear in Nature From one point of view, zero never appearing in nature is exactly an example of it appearing in nature! From another point of view, do you not think a prairie dog has ever asked another prairie dog, "how many foxes are out there now?" with the other looking and replying "None! All clear!"? Crows can count to at least 5, and will count down until th…

> From another point of view, do you not think a prairie dog has ever asked another prairie dog, "how many foxes are out there now?" with the other looking and replying "None! All clear!"?

  type PrairieDogFoxCount = NoFoxesAllClear | SomeFoxes 1..5 | TooManyFoxes

  type CrowCount = Some 1..5 | UpsideDown 5..1

  type HumanProgrammerCount = 0..MAXINT

  type HumanMathematicianCount = 0..∞
My point is: "No Foxes - All Clear" is not the same thing (the same level of abstraction) as 0.

> From a third point of view, humans are natural, so everything we do appears in nature.

using this definition everything is Natural, including fore example Complex numbers, which is obviously incorrect, and thus invalidates yr argument

> From a fourth point of view, all models are wrong, but some models are useful. Is it more useful to put zero in the natural numbers or not? That is: if we exclude zero from the natural numbers, do we just force 90% of occurrences of the term to be "non-negative integers" instead?

all models are wrong, but some are really wrong

If all u care is the length of the terms, i.e. "Natural" vs "non-negative integers", then what's wrong with 1-letter set names, like N, W, Z ?

I think the usefulness of including 0 into the set of natural numbers is that it closes the holes in various math theories like [1,2]

1. https://en.wikipedia.org/wiki/Peano_axioms

2. https://en.wikipedia.org/wiki/Set-theoretic_definition_of_na...

Re: Numbering should start at zero (1982)

#236

1-based numbering is nonsense. How many years old are you when you’re born? I notice almost all defenses of 1-based indexing are purely based on arbitrary cultural factors or historical conventions, e.g. “that’s how it’s done in math”, rather than logical arguments.

Another idiot confusing continuous measure (time) with counting discrete units

If it helps: you have one whole array element only if one year has passed

What are you trying to do: do you want to know where each element starts, or do you want to measure the total sum/accumulated amount?

Re: Numbering should start at zero (1982)

#237
post #171

Earlier quoted context omitted.

That sounds reasonable at first, but humans are messy and so the distinction is not always clear. For example, in music we use numbers for the notes of a scale (G is the 5th of C, because in the C major scale: C=1, D=2, E=3, F=4, G=5, A=6, B=7). The numbers are clearly indices for the notes of the scale. But we often think of stuff like: what's the 3rd of the 5th -- that is, get the note at the 5th position (G in our…

Yeah, because the scale is an index (e.gm A=6) but the operations are offsets in that case. Because if you moved from G/5 to B/7 that is clearly 2.

Yes, that's the point: the numbers are used as both indices and offsets. To any musician or music student, moving from G to B is "going up a (major) third", even though it's obviously going up by 2 notes. The name of that offset ("interval" in music speak) is "third", even though it has a distance of 2 notes.

My point (more generally) is that even though it looks reasonable to make indices start from 1 and offsets from 0, in practice these things can get mixed together. It's not reasonable to get people to use two different numbers for what they see as the same thing (because their use got mixed).

Re: Numbering should start at zero (1982)

#238
post #208

I'll upvote this Djisktra note every time it appears. :-) It settles the discussion of array numbering. F*ck off Visual Basic, MS Javascript, and all the languages that said you should start with 1.

Matlab, Fortran, Julia, R, SAS, SPSS, Mathematica, and the whole field of mathematics. F*ck off all mathematicians, what do they know about counting?

Re: Numbering should start at zero (1982)

#240

Earlier quoted context omitted.

[closed, open) intervals on the number line are well-known in math, as are operations on them. -0 is not, nor supported by hardware.

Yes, but Python is not math. This is a syntax-feature we are talking about, math is here just a tool, not the purpose. And it's also not running on hardware, but multiple layers higher.

Python already has the best design (fewest tradeoffs) in this small area.

You're proposing to break the expectations of millions and break offset math while you're at it. Not very compelling if you ask me.

Post reply on HN