Live data from Hacker News

Numbering should start at zero (1982)

cs.utexas.edu

121–130 of 309 posts

Re: Numbering should start at zero (1982)

#121
post #25
post #11

I found it devastating that there are no distinct agreed-upon words denoting zero- and one-based addressing. Initially I thought that the word "index" clearly denotes zero-base, and for one-base there is "order", "position", "rank" or some other word, but after rather painful and humiliating research I stood corrected. ("Index" is really used in both meanings, and without prior knowledge of the context, there is real…

AFAIK "offset" (i.e. from the beginning of the array/file/etc) is commonly used to indicate a zero-based index.

I like this. I feel like "offset" hints at the reason for starting at 0. "How far do you have to offset your feet (from the beginning of whatever space we're talking about) before you're touching the thing in question?" If it's the first thing, you don't have to move at all, so zero offset

Re: Numbering should start at zero (1982)

#122

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…

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.

Re: Numbering should start at zero (1982)

#123
post #103

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…

I totally disagree, but it's only my opinion and probably not scientific at all. From a logical point of view I think it's totally unnatural to start at 1. You have 10 diffferent "chars" available in the decimal system. Starting at 1 mostly leads to counting up to 10. But 10 is already the next "iteration". How do you explain a kid, who's learning arithmetics, that the decimal system is based on 10 numbers and at the…

Decimal system is simply a notation chosen by Humans to communicate and preserve information, it’s not a Law of Nature.

Also you use a circular reasoning.

Re: Numbering should start at zero (1982)

#124
post #11

I found it devastating that there are no distinct agreed-upon words denoting zero- and one-based addressing. Initially I thought that the word "index" clearly denotes zero-base, and for one-base there is "order", "position", "rank" or some other word, but after rather painful and humiliating research I stood corrected. ("Index" is really used in both meanings, and without prior knowledge of the context, there is real…

I don't think "index" by itself should imply any starting value. After all many induces start at higher numbers and then you'd have to invent words for 2-based, 3-based and so on as well.

Maybe we can call it 0ndex and 1ndex. Really rolls off the tongue.

Re: Numbering should start at zero (1982)

#125
post #55

Earlier quoted context omitted.

> How many years old are you when you’re born? You have lived zero full years and are in the first year of your life. In most (but not all) countries the former is considered "your age". That's consistent with both zero-based and one-based indexing. Both agree on cardinal numbers (an array [1, 2] has length 2), just not on ordinal numbers (whether the 1 in that array is the "first" or "zeroth" element). > I notice al…

Both agree on cardinal numbers (an array [1, 2] has length 2), just not on ordinal numbers (whether the 1 in that array is the "first" or "zeroth" element). I think whenever people say "zeroth" they speak in jest and doubt that there is any disagreement on the fact that the element without predecessor (nowadays in programming most often assigned index 0) is the first element. You used "first" in that sense naturally…

> I think whenever people say "zeroth" they speak in jest and doubt that there is any disagreement on the fact that the element without predecessor (nowadays in programming most often assigned index 0) is the first element.

"Zeroth" sounds silly because English has generally settled on one-based indexing, and so typically you'd convert to one-based indexing when speaking out loud or writing something other than code (`users[3]` is the "4th user").

Maybe you could argue that the words "first"/"second", as just some letters/sounds, are not inherently one-based? But I feel that gets a bit dubious from "third" onwards where the connection to numbers is obvious, and with the ordinals frequently spelled as 1st/2nd/etc.

But, if you want (and if I'm understanding what you mean), you could replace my statement with: "whether the '1' in that array is the index-1 or index-0 element" - purpose was just to distinguish between ordinals and cardinals, in response to a comment that seemingly implied the cardinality of an empty collection would be 1 with one-based-indexing.

Re: Numbering should start at zero (1982)

#126

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…

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.

U are u man wizard. It's probably slightly jarring to see u r instead of you're, but I did not even notice it at first glance.

Like the sibling comment says, we're all semi anonymous internet folks talking about mostly not serious things.

Re: Numbering should start at zero (1982)

#127

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…

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 fully agree, youmanwizard.

Re: Numbering should start at zero (1982)

#128
post #96

I see people bringing up arrays, and an array index is represented by a number, you can do math on it, but it's not a regular number for counting a sequence of items. It's a unique reference to a location in the memory, and it's dangerous to treat an array index like it's just any old number. Behold, the really stupid things you can do in Javascript: let myArr = []; let index = 0; myArr[--index] = 5; console.log(myAr…

An index is a specific kind of number, but so is a count.

Indexing should clearly start from 0. It leads to far more elegant code and lower risk of off-by-one mistakes.

Re: Numbering should start at zero (1982)

#129
post #117

Whenever I explain to someone when or why to use 0-indexing, I like to say: Start from 0 if you are counting boundaries (fenceposts, memory addresses) Start from 1 if you are counting spaces (pages in a book, ordinals) Floors are a case where both make intuitive sense, which is maybe how we ended up with European vs American floor numbering.

That's a very confused way of thinking about it IMO. I say:

* Start from 0 if you are indexing. I.e. you are identifying an item or its position.

* Start from 1 if you are counting. I.e. you are saying how many items there are.

It doesn't matter what it is. I don't know why you think pages in a book are somehow different to memory addresses.

Post reply on HN