Ehh, this post misses the important tidbid.<p>You should keep your code consistent across your organization, so that a large number of programmers knows how your code works. You should have a "default writing style", and the "default writing style" should be used unless you have very, very, very good reasons to avoid it. (And an errant +1 or -1 here and there isn't a good enough reason to switch).<p>There are four styles of intervals. Lets say you want to represent a loop of 5 iterations numbered [555, 556, 557, 558, 559]. You've got:<p>* [closed, closed] -- [555, 559]<p>* [closed, open> -- [555, 560><p>* <open, closed] -- <554, 559]<p>* <open, open> -- <554, 560><p>There's not much difference to any of these four. As long as you pick a singular choice, get comfortable with its quirks, and make it consistent across your organization, you get benefits.<p>The main reason we do [closed, open> is because Dijkstra (father of structured programming back in the 1960s), argued to use [closed, open>, when presented with all these options. (and argued for zero-indexed as well).<p>The "[closed, closed]" set is one-too-small (559 - 555 == 4), so you need to add +1 to the representation.<p>The <open, open> set is one-too-large: (560 - 554) == 6. So this too seems prone to off by one error.<p>[closed, open> and <open, closed] are both the correct size of 5 when you subtract, but both "includes" a number that doesn't exist. In [closed, open>, the latter number isn't part of the array (560 is "one past the end), while in <open, closed>, the first number isn't part of the array.<p>Make that what you will of it. [closed, open> became a programmer convention because of these reasons. The important bit is to know all the quirks / off by one errors associated with this representation.