Live data from Hacker News

Numbering should start at zero (1982)

cs.utexas.edu

191–200 of 309 posts

Re: Numbering should start at zero (1982)

#191
post #187

Earlier quoted context omitted.

Zero is a natural number. It is in the axioms of Peano arithmetic, and any other definition is just teachers choosing a taxonomy that best fits their lesson.

> Zero is a natural number. It is in the axioms of Peano arithmetic, and any other definition is just teachers choosing a taxonomy that best fits their lesson. It is, but it need not be. In the category of pointed sets with endofunctor, (Z_{\ge 1}, 1, ++) and (Z_{\ge 0}, 0, ++) are isomorphic (to each other, to (Z_{\ge 937}, 937, ++), and to any number of other absurd models), so either would do equally well as a mod…

I may be misunderstanding your argument, but if it's that of a simple offset, then only the one starting from 0 forms a monoid (a group without an inverse to each element). Though, of course, you could redefine the + operation...

Re: Numbering should start at zero (1982)

#192
post #173

Earlier quoted context omitted.

+1 for peano arithmetic club. I never realized it was controversial. I think I've always included 0 in the nat numbers since learning to count. But there are some programming books I've read, I want to say the Little Typer, or similar, that say "natural number" or "zero". Which makes actually confuses me.

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 there are zero humans in a silo before returning to it. Zero influences animal behavior!

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

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?

Re: Numbering should start at zero (1982)

#193

I've always appreciated Ada's approach to arrays. You can create array types and specify both the type of the values and of the index. If zero based makes sense for your use, use that, if something else makes sense use that. e.g. type Index is range 1 .. 5; type My_Int_Array is array (Index) of My_Int; It made life pretty nice when working in SPARK if you defined suitable range types for indexes. The proof steps were…

On the other hand, if you receive an unconstrained array argument (such as S : String, which is an array (Positive range ) of Character underneath), you are expected to access its elements like this:

    S (S'First), S (S'First + 1), S (S'First + 2), …, S (S'Last)
If you write S (1) etc. instead, the code is less general and will only work for subarrays that start at the first element of the underlying array.

So effectively, indexing is zero-based for most code.

Re: Numbering should start at zero (1982)

#194

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 French (and likely other Latin languages?) are not quite so lucky. "En 8" means in a week, "une quinzaine" (from 15) means two weeks...

Hmm, "en 8" makes sense to me in that you're using it to reference the next Whateverday that is at least 8 days apart from now.

If we're on a Tuesday, and I say we're meeting Wednesday in eight, that Wednesday is indeed 8 days away.

Now I'm fascinated by this explanation, which covers the use of 15 as well. I'd always thought of it as an approximation for a half month, which is roughly 15 days, but also two weeks.

To partially answer the other Latin languages, Portuguese also uses "quinze dias" (fifteen days) to mean two weeks. But I don't think there is an equivalent of the "en huit". We'd use "na quarta-feira seguinte" which is equivalent to "le mercredi suivant".

Re: Numbering should start at zero (1982)

#196

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. *…

In terms of another thread the item is the "rail" between the "fence posts". The address of the 'first' item starts at 0, but it isn't complete until you've reached the 1.

Where is the first item? Slot 0. How much space does one item take up* (ignoring administrative overheads)? The first and only item takes up 1 space.

Re: Numbering should start at zero (1982)

#197

Earlier quoted context omitted.

Why do you write “you” as “u” here? I don’t want to be rude, but it’s very jarring to see juvenile txt-speak in a serious discussion.

I have started using “u” in my posts as there are a surprising number of sites that block or delay for approval posts that use “you”. They seem to feel that posts with “you” are too often inflammatory. It is very frustrating when you use grammatical “you” as I just did and suddenly your post is stuck in limbo.

What sites? I have never heard of anything like that.

Re: Numbering should start at zero (1982)

#198

Earlier quoted context omitted.

It's interesting how most people find learning 0-based indexes confusing, but after a few years of programming, they don't even notice how odd it is. How do you number things in real life? If you have two options, do you number them "option 0" and "option 1" or "option 1" and "option 2"? If you create a presentation with numbered bullet points, do you start numbering them from 0 or 1? 1. This is my first point 2. Thi…

Your arguments using "first" and "second" are invalid, because those words have nothing to do with numbers, like also "last". If you argue based on English, you should point only to the ordinals "third", "fourth" and the like. In the older European languages, the initial position in a sequence was named using words like "first", which mean "closest to the front". The next position was named with words meaning "the ot…

> Your arguments using "first" and "second" are invalid,

> because those words have nothing to do with numbers

"First" is the ordinal number corresponding to the number one, while "second" is the ordinal number corresponding to the number two. You can represent "first" as 1st and "second" as 2nd. I believe the origins of these two words do not significantly impact my argument.

Re: Numbering should start at zero (1982)

#200

Earlier quoted context omitted.

Yes, it's the offset from a pointer in some languages. But to the user, it's presented as an index, not an offset. In normal syntax, you don't access an array value using a construct like *(arraypointer+offset) If you did that, then using 0 as the start offset would make intuitive sense. In fact, if not for this technical reason, I doubt that any programming language would have 0-based indices.

im not debating the user level stuff. honestly i think there's fair argument for not letting users get bogged down in system level details. but in my opinion, if people dont understand this why, its a useful thing to learn. its only a small detail in the end. i think, because software is built up abstractions over abstractions, its unavoidable such details creep into languages from the depths of the system. its not t…

I don't disagree with anything you say. I'm not saying that C should have 1-based indices, for example. I'm only saying that from a language design perspective, ignoring technical limitations and historical precedents, 1-based indices would be preferable.
Post reply on HN