Indices Point Between Elements
blog.nelhage.com
Indices Point Between Elements
1–10 of 66 posts
Re: Indices Point Between Elements
#2It used to be popular, and still is in some circles, to debate whether programming languages ought start array indexing at 0 or 1.
When talking about this with other programmers, I've discovered that a lot of the issues/confusion could be avoided by consistent use of terminology: Offsets/offsetting always being zero-based and indexes/indexing always being one-based.
Using rulers and birthdays also helps to explain differences. You're in the first year before your first birthday, being zero (whole) years old.
To make matters potentially more confusing, culturally, I remember something about the ground floor in the UK buildings not being "Floor 1" like it is in the United States.
Re: Indices Point Between Elements
#3Re: Indices Point Between Elements
#4Re: Indices Point Between Elements
#5Re: Indices Point Between Elements
#6Re: Indices Point Between Elements
#7Re: Indices Point Between Elements
#8See also https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E... ("Why numbering should start at zero")
Re: Indices Point Between Elements
#9edit: Probably the most popular genome browser, based at UC Santa Cruz, uses this zero-based, half-open numbering internally. But, at some point in the past, biologists developed an expectation that numbering would be 1-based. So the Santa Cruz genome browser actually adds 1 to the start position of everything for display purposes.
Re: Indices Point Between Elements
#10The visuals are definitely valuable in explaining this. It used to be popular, and still is in some circles, to debate whether programming languages ought start array indexing at 0 or 1. When talking about this with other programmers, I've discovered that a lot of the issues/confusion could be avoided by consistent use of terminology: Offsets/offsetting always being zero-based and indexes/indexing always being one-ba…
Actually, that's perfectly explained with your offset vs. index terminology. In some countries, the floor number is an index within the array of floors. In others, it's an offset from the ground.