News for hackers. Stuff that matters.
Re:Why do arrays start at 0? by dathinab on Wednesday August 24, 2022 @08:56PM (#32587966)
Defining index as the element wise offset is a precise well formed definition/name.

It's also a definition commonly used in math, through not always. It depends a lot of the area of mathematics and even the cultural context.

The only reason we sometimes feel 0-index is wrong IMHO is because the english language describes entities in a sequence as 1st, 2nd, 3rd etc.

But I wouldn't be surprised if there is some human language somewhere which does it differently. Like something which roughly matches to english like "head, head+1, head+2, ...".

Re:Why do arrays start at 0? by biztos on Wednesday August 24, 2022 @09:26PM (#32588217)
Which floor is the first floor in your building?

Depends which country your building is in, and more!

My apartment building is 1,2… but my mall is G,M,1,2… (same country different architects). For many years I lived in Europe where it’s usually G,1,2… (where G can also be E or Fsz or whatever) and when I was in the US I had to remember that 1 is G, though L,2,3… is also common.

City people live with index ambiguity all the time and our brains manage just fine.

Re:Why do arrays start at 0? by joaonmatos on Wednesday August 24, 2022 @09:34PM (#32588285)
Quick complement. Where I’m from (Portugal) we use the literal number 0 for the ground floor.
Re:Why do arrays start at 0? by avereveard on Wednesday August 24, 2022 @11:57PM (#32589310)
In Europe is common for elevator to use zero for ground, even if language/culture has a specific name for it (piano terra/piano rialzato here)
Re:Why do arrays start at 0? by fjkdlsjflkds on Thursday August 25, 2022 @03:08AM (#32590543)
Actually, "rés-do-chão" would be the more common term. Still... in Portugal, the "first floor" is implicitly never the ground floor (but the floor above it), so 0-based indexing is respected (as you suggest).
Re:Why do arrays start at 0? by joaonmatos on Thursday August 25, 2022 @12:49PM (#32596415)
On elevators you don’t see “R/C” unless the elevator is very old, and the same for office building directories or shopping centres. In almost all cases it’s the number zero. OTOH, in countries like Germany you will see the “E” for Erdgeschoss everywhere.
Re:Why do arrays start at 0? by dathinab on Friday August 26, 2022 @07:00PM (#32613726)
> Which floor is the first floor in your building?

0.5 ... yep that won't work

In some buildings build around 1900 where I live the "ground" floor is not on the ground but around 1/2 a floor above the ground floor. While the cellar is just half below the ground. Because of this the cellar has above ground level windows allowing legal cellar apartments (oversimplified in Germany apartments require windows which are above ground).

This creates a lot of confusion.

By convention this 0.5 floor still counts as ground floor with the floor number 0. But people confuse it all the time for the first floor. Especially if in some cases you do have a few utility rooms exactly at ground floor.

Now things get worse if you live in a cellar apartment in such house: By convention floor -1.

Because nearly everyone will thing you mistyped as normally you legally can't have apartments below the ground floor.

Another fun index ambiguity is for apartments build on a mountain side/cliff.

In this case depending on which side of the house you look at the ground floor might be at, above or below the ground level. Often the floor level with the main entrance counts as ground floor, but sometimes it is not the case and e.g. the lowest floor not below ground or the highest floor even with a "ground".

So yes, index/floor level ambiguity is everywhere and much worse then just is ground floor 0 or 1 ;)

Re:Why do arrays start at 0? by rswail on Thursday August 25, 2022 @02:40AM (#32590379)
Not only that but which floor is the 13th (in the West) or 14th (in China)? Often those numbers are skipped because "luck", "feng shui", or other superstitious nonsense.

Do you count the machine floors in high rise buildings?

In AU, the ground floor is effectively "zero", the first floor is the one above ground. Depending on the design of the building, there might be a "mezzanine" floor between ground and 1st.

Basements usually follow the same pattern, so B1 is the first floor below ground etc.

Re:Why do arrays start at 0? by nawitus on Thursday August 25, 2022 @03:27AM (#32590689)
In one department store in Finland there are two separate numbering schemes, see this photo from the elevator: https://hs.mediadelivery.fi/img/some/default/c244c43c3008429...
Re:Why do arrays start at 0? by lkuty on Thursday August 25, 2022 @12:51AM (#32589634)
In Belgium (french speaking part of the country, like in France) we call the ground floor (where you enter the buidling) "rez-de-chaussée" (or "rez" for short) which is the equivalent of 0 and then the first floor, numbered 1, is on top of it and you use an elevator or stairs to reach it.
Re:Why do arrays start at 0? by 2143 on Wednesday August 24, 2022 @09:41PM (#32588352)
Yes, where I'm at — large country in Asia — we count floors starting from 0 (aka G for Ground).

Confused me when I visited USA.

Re:Why do arrays start at 0? by Tao3300 on Wednesday August 24, 2022 @10:09PM (#32588564)
G or L (for lobby) followed by 1 isn't uncommon in the US.

> Confused me when I visited USA

It's applied inconsistently enough to be confusing for natives too!

Re:Why do arrays start at 0? by 988747 on Thursday August 25, 2022 @05:09AM (#32591350)
I've just come back from the vacation in the US, and my experience was: when the hotel has G or L for the ground floor, it still has 2 for the floor directly above it. "G or L followed by 1" never happened to me.
Re:Why do arrays start at 0? by loonster on Wednesday August 24, 2022 @10:35PM (#32588737)
It's the consistent inconsistencies that causes it to be less confusing. It would be really weird to go from someplace very orderly to another that is haphazard.
Re:Why do arrays start at 0? by kgwxd on Wednesday August 24, 2022 @09:38PM (#32588323)
> Defining index as the element wise offset is a precise well formed definition/name.

But it's less precise than offset and obviously introduces confusion. Whoever originated the term "0-indexed" should have just suggested we use a better word rather than keeping the inaccurate word (proven by the fact you're currently looking for a way to remove some confusion around the currently chosen word) and prefixing it with a digit, which itself is a confusing thing to do to an English word, thus adding to the confusing while subtracting none.

Re:Why do arrays start at 0? by dathinab on Friday August 26, 2022 @08:11AM (#32606333)
you can say the same for 1-indexed, because from the get to go both existed.

Also it's not less precise, as there are many different kinds of offsets too. First you have element wise and byte wise and similar offsets, then offsets are inherently relative to something, and that's not always the first element. But could be an offset from the back and I have even seen a offset from one element before the first element in some very unusual use-cases.