News for hackers. Stuff that matters.
Re:Again on 0-based vs. 1-based indexing by tremon on Wednesday January 20, 2021 @08:22AM (#25846089)
It is non-intuitive, but it doesn't happen only in programming. Look at sports reporting, for example (basketball, football). When they say something happened "in the 6th minute", it happened between 05:00 and 05:59. The difficulty isn't solely with programming.

You can use the same mechanism (minutes:seconds) to explain the half-open ranges: does a range(0,30) mean from 0:00 to 30:00 or from 0:00 to 30:59? If the second half of the match starts at 30:00, does the first half really end at 30:00 or is it really 29:59:99...9?

For most basic concepts, there's always real-world examples to use so that the teaching doesn't have to be abstract.

Re:Again on 0-based vs. 1-based indexing by userbinator on Wednesday January 20, 2021 @09:23AM (#25846744)
There's another non-intuitive and also inconsistent usage of ranges that I find rather confusing: if you say that a meeting is from 9 to 10, it's one hour long. If you say that you'll be on vacation from January 20 to 21, most people seem to think that means two days.
Re:Again on 0-based vs. 1-based indexing by TuringTest on Wednesday January 20, 2021 @10:43AM (#25847725)
That's because hours are announced as points in time, while days are seen as time intervals. The duality intervals/separators is essential to the different ways to understand ranges (specially for range differences).

I once developed a shortcut notation to simplify reasoning about ranges differentiating between "point cero" and "interval between 0 to 1", to make off-by-one errors less likely, but in the end it was functionally equivalent to the popular open/closed interval notations.

Re:Again on 0-based vs. 1-based indexing by TuringTest on Wednesday January 20, 2021 @11:39AM (#25848482)
If anyone is interested in a notation for this kind of integer ranges, the two different styles in the above example could be represented like this:

   /9..10\  : "short" interval : size 1 (hour)  ==  half-open interval [9..10)
 -|20..21|- :  "long" interval : size 2 (days)  ==  closed interval   [20..21]
Re:Again on 0-based vs. 1-based indexing by rytis on Wednesday January 20, 2021 @09:41AM (#25846948)
Specifying vacation range got me in to few confusing situations, so I have a habit now announcing them as: "I'm on vacation from X to Y, returning to the office on Z"...
Re:Again on 0-based vs. 1-based indexing by psychoslave on Wednesday January 20, 2021 @11:21AM (#25848243)
1 hour meeting -> meeting start at 9 and is expected to finish when it’s no longer 9 1 day vacation -> vacation start on January 20 and is expected to finish when it’s no longer January 20.

Ultimately, it relies on conventions, but I guess now you can see how this one relies on something which has some consistent pattern.

Re:Again on 0-based vs. 1-based indexing by iimblack on Wednesday January 20, 2021 @12:35PM (#25849268)
I thought the proper way to say this is January 20 through 21, but seems like most people don't follow this. Probably because it's often abbreviated as 20-21, which is often used for both cases.
Re:Again on 0-based vs. 1-based indexing by teekert on Wednesday January 20, 2021 @08:24AM (#25846107)
Yeah and kids are actually aged "1" in their second year.
Re:Again on 0-based vs. 1-based indexing by improbable22 on Wednesday January 20, 2021 @08:45AM (#25846334)
Time is a continuous variable, and kids know this pretty early on: they will happily tell you they are 5 and a half years old. Their second year starts when they are aged 1.0.

English in general makes this distinction: "He is fewer than 6 years old" is simply a mistake, while "less than 6 years old" is fine. (I think some dialects use "fewer" less often, in general, but would be pretty surprised if any prefer it here.)

Re:Again on 0-based vs. 1-based indexing by aqme28 on Wednesday January 20, 2021 @11:50AM (#25848657)
Your "first" birthday is actually your second birthday.
Re:Again on 0-based vs. 1-based indexing by tremon on Wednesday January 20, 2021 @01:00PM (#25849606)
To be pedantic, it's the first annual celebration of your birthday.

Other languages use a less confusing term for it: anniversaire (French) is just anniversary, verjaardag (Dutch) roughly means year-rollover-day, and cumpleaños (Spanish) signifies completion of another year.

Re:Again on 0-based vs. 1-based indexing by tremon on Saturday January 23, 2021 @08:00AM (#25881882)
I just realized something: anniversaire has the same root as the other examples I gave. It comes from the latin words annus and verso, which mean "year" and "to turn over" respectively.
Re:Again on 0-based vs. 1-based indexing by FigmentEngine on Wednesday January 20, 2021 @03:36PM (#25851635)
its the same in English:

late 14c., from Old English byrddæg, "anniversary or celebration of one's birth" (at first usually a king or saint); see birth (n.) + day. Meaning "day on which one is born" is from 1570s. Birthnight is attested from 1620s. https://www.etymonline.com/word/birthday#etymonline_v_27158

Re:Again on 0-based vs. 1-based indexing by rmah on Wednesday January 20, 2021 @08:57AM (#25846474)
In korea, they'd be age 2. There (and possibly other east asian nations?) count "age" in terms of which year you're in. 1st year, 2nd year, 3rd year, etc. The way americans do school year, except it starts at birth.
Re:Again on 0-based vs. 1-based indexing by jzwinck on Wednesday January 20, 2021 @09:05AM (#25846553)
In Korea everyone advances their age on 1 January. Korean babies born three weeks ago are now age 2 (and have been for most of their lives).
Re:Again on 0-based vs. 1-based indexing by klik99 on Wednesday January 20, 2021 @09:20AM (#25846706)
When my korean friend first told me this, I honestly thought they were messing with me. I still struggle to make sense of it. Must be a helluva birthday party on Jan 1st tho

I know there are studies on how birth date affects future success in school (though IIRC I read in Gladwell, and I'm wary of accurate his read on things are), I wonder if that effect is compounded with this system?

Re:Again on 0-based vs. 1-based indexing by naniwaduni on Wednesday January 20, 2021 @09:41AM (#25846947)
It's just a count of how many calendar years contain you.
Re:Again on 0-based vs. 1-based indexing by ska on Wednesday January 20, 2021 @12:05PM (#25848847)
It's the difference between "I was born in 2010" and "I am about 10.3 years old".

Americans do this a lot too, except at a (pseudo) decade level, e.g. "are you a '90s kid?"

Re:Again on 0-based vs. 1-based indexing by cgriswald on Wednesday January 20, 2021 @01:29PM (#25850024)
> Americans do this a lot too, except at a (pseudo) decade level, e.g. "are you a '90s kid?"

This brings up other ambiguities. A "90's kid" might have been born in the 80's.

Re:Again on 0-based vs. 1-based indexing by ska on Wednesday January 20, 2021 @03:35PM (#25851629)
Yes, it’s not a clean mapping
Re:Again on 0-based vs. 1-based indexing by rmah on Wednesday January 20, 2021 @12:35PM (#25849257)
They're in their second year.
Re:Again on 0-based vs. 1-based indexing by randomdata on Wednesday January 20, 2021 @01:28PM (#25850016)
> The way americans do school year

You could say that the American school year is 0-based. Except instead of naming it zeroth grade, it is named kindergarten.

Re:Again on 0-based vs. 1-based indexing by AuthorizedCust on Wednesday January 20, 2021 @08:48AM (#25846362)
What we call “age” is merely the number of the most recent birth anniversary we’ve passed. That makes sense. While your take isn’t invalid, it sets up a less intuitive construct that isn’t aligned with the common meaning of the word.
Re:Again on 0-based vs. 1-based indexing by jjaredsimpson on Wednesday January 20, 2021 @10:02AM (#25847186)
> does the first half really end at 30:00 or is it really 29:59:99...9?

those are the same number.

Re:Again on 0-based vs. 1-based indexing by Jtsummers on Wednesday January 20, 2021 @10:50AM (#25847820)
By putting a terminal 9 there it's no longer "point 9 repeating" but "some arbitrary, but finite, number of 9s after the decimal".
Re:Again on 0-based vs. 1-based indexing by thunderbong on Wednesday January 20, 2021 @09:44AM (#25846986)
Exactly the same as 21st century meaning everything between 2000 - 2099
Re:Again on 0-based vs. 1-based indexing by grawprog on Wednesday January 20, 2021 @11:17AM (#25848197)
But back in 2000 I remember there were debates on whether the new century/millenium started in 2000 or 2001.
Re:Again on 0-based vs. 1-based indexing by _0ffh on Wednesday January 20, 2021 @11:42AM (#25848543)
Yeah, seems like the 21st century should be 2001-2100.
Re:Again on 0-based vs. 1-based indexing by novaleaf on Wednesday January 20, 2021 @07:40PM (#25853864)
24hr time is also 0th based :)