Both have inconsistencies, like in Spain you might have a "middle ground" (entresuelo) which is neither 0 nor 1, but sits between, and is normally commercial or non-livable, reserving the 1 to the first floor where people live. I like that system better though because it usually goes 1 => 0 => -1 (underground), while in Japan you go 2 => 1 => -1, so I feel like it's missing a floor. You could justify it though as 0 being the ground line, so +1 is "the first above the floor and -1 is "the first below the floor", but I still prefer having each floor to be a natural consecutive number.
Why do arrays start at 0?
51–60 of 702 posts
Re: Why do arrays start at 0?
#52It really comes down to a choice between a machine-focused (0) or human-focused (1) approach. The 0 makes a lot of sense in a C pointer world where memcpy and other alike functions can be written very thight. The 1 makes a lot of sense in a human world, when we count, we start at 1, we talk about the "1st", counting on finger starts with 1, etc. I once were at a Lua (1 indexed language) conference where this was disc…
That is false; counting begins by initializing an accumulator to zero. When you register the first item, the count jumps from 0 to 1.
Re: Why do arrays start at 0?
#53Re: Why do arrays start at 0?
#54Earlier quoted context omitted.
No, birthdays are 1 indexed. Your Nth birthday is the day you turn N years old. When you're 1 year old, you've been alive for 1 year, not 2 years.
So how old is a not-yet-1-year old?
Another definition might be from conception. But birth being “one year old” is illogical. The sperm didn’t even exist yet, one year before birth.
Re: Why do arrays start at 0?
#55Earlier quoted context omitted.
The moment you are born you are 0 years old (or perhaps 0.75 years old, but we don't usually recognize that). We count from zero in this case, at least implicitly. In some cultures you are considered 1 the moment you are born, so the zero indexing isn't universal here, but typical in North America as noted earlier.
No, we don't count from 0. That's like saying we start counting a baker's cup from 0 because you can have half a cup.
Re: Why do arrays start at 0?
#56Re: Why do arrays start at 0?
#57It really comes down to a choice between a machine-focused (0) or human-focused (1) approach. The 0 makes a lot of sense in a C pointer world where memcpy and other alike functions can be written very thight. The 1 makes a lot of sense in a human world, when we count, we start at 1, we talk about the "1st", counting on finger starts with 1, etc. I once were at a Lua (1 indexed language) conference where this was disc…
If you think of the index as an offset you would start with 0. BTW on which level is the 1st floor?
Again, this is more a spoken language/culture thing, and this goes back to what premises we use to communicate with the machines, ours or the machines...
Re: Why do arrays start at 0?
#58Earlier quoted context omitted.
The moment you are born you are 0 years old (or perhaps 0.75 years old, but we don't usually recognize that). We count from zero in this case, at least implicitly. In some cultures you are considered 1 the moment you are born, so the zero indexing isn't universal here, but typical in North America as noted earlier.
No, we don't count from 0. That's like saying we start counting a baker's cup from 0 because you can have half a cup.
Suppose your job is to count some events. You check in for work at 8:00 a.m., but the first event has not registered until noon. By your logic you should not be paid for four hours, because you're paid to count, and counting started at 1.
Re: Why do arrays start at 0?
#59 type Day is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
type Hours is array (Day range ) of Natural;
V : Hours (Monday .. Friday);
Which index type you should use depends on the problem that you're trying to model. You can find out the lower/higher end of a type/variable with the 'First and 'Last attributes.IIRC there's an RFC though to force the lower end of the index to a certain value like 1 or any other number/enum.
Re: Why do arrays start at 0?
#60Earlier quoted context omitted.
> when we count, we start at 1, we talk about the "1st" Although often with an implicit zero. Under typical North American culture, your 1st birthday, for example, is more accurately the first anniversary of your birthday. Your birth is zero indexed.
Yeah age is confusing even for non-computer-folks :) If you have 4 classes in school today, you would never talk about the 1st class as number 0, the last one is the 4th, not the 3rd.