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.
Numbering should start at zero (1982)
121–130 of 309 posts
Re: Numbering should start at zero (1982)
#122Numbering 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.
Re: Numbering should start at zero (1982)
#123Numbering 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…
Also you use a circular reasoning.
Re: Numbering should start at zero (1982)
#124I 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.
Re: Numbering should start at zero (1982)
#125Earlier 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…
"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)
#126Numbering 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.
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)
#127Numbering 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.
Re: Numbering should start at zero (1982)
#128I 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…
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)
#129Whenever 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.
* 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.