Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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.


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.


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]


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"...


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.


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.


Yeah and kids are actually aged "1" in their second year.


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.)


Your "first" birthday is actually your second birthday.


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.


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.


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


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.


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).


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?


It's just a count of how many calendar years contain you.


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?"


> 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.


Yes, it’s not a clean mapping


They're in their second year.


> 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.


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.


> does the first half really end at 30:00 or is it really 29:59:99...9?

those are the same number.


By putting a terminal 9 there it's no longer "point 9 repeating" but "some arbitrary, but finite, number of 9s after the decimal".


Exactly the same as 21st century meaning everything between 2000 - 2099


But back in 2000 I remember there were debates on whether the new century/millenium started in 2000 or 2001.


Yeah, seems like the 21st century should be 2001-2100.


24hr time is also 0th based :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: