Where should we start counting, 0 or 1?

Here’s something you might do when you’re writing a computer program:

$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

This happens to be a bit of the PHP computer language, but similar constructions are available in almost any language: this defines an array – a “collection,” you might say – of months. You don’t have to be a computer programmer to realize that this would have utility in any number of computer programs: collecting credit card expiration dates or birth dates, allowing a search of a database of events by month, and so on.

One of the rookie mistakes we all made when we first started programming is to think that when we, say, want to refer to the month of May, we’d refer to:


May is, after all, the fifth month, and in a collection of months it would only make sense, wouldn’t it, that May would be referenced as such?

Except that PHP, by default, uses zero-based arrays. Which means that in my array of months the first month is 0, the second month is 1, the third month is 2, and so on. Meaning that the month of May is actually referenced as:


This is something that causes no end of confusion for the novice programmer. And, indeed, for the veteran as well, on occasion.

You might think that this is a post about computer programming, but it’s not.

Longtime readers may recall the story I posted here about taking the metro in Porto, Portugal, ten years ago this week: that story too involved zero-based counting.

To refresh your memory, Catherine and Oliver and I were nabbed by the Porto transit cops for traveling without a proper ticket. We were taking Line A from Senhor de Matoshinhos to Campanhã, where we were to catch the train. Here’s the list of stops on that line:

Porto Metro Line A Map

Porto uses a zoned ticketing system, and we reasoned that because Senhor de Matoshinhos was in Zone C3 and Campanhã was in Zone C1, we would need a 2-zone ticket, as we’d be crossing two zone boundaries. 

In other words, we assumed the metro system used zero-based numbering for its ticketing: we started counting 0 in Zone C3, then 1 for Zone C2 and 2 for Zone C3. And so we bought 2-zone tickets.

But Porto’s metro uses a one-based numbering system for its ticketing: you start counting 1 for the zone you’re starting in, and count up from there. Which means that to go from Senhor de Matoshinhos to Campanhã we needed a 3 zone ticket.

The same issue bit me last December in Montreal, albeit counting days, not zones.

In Montreal you can buy a 3-day transit pass valid for unlimited travel across the system. Oliver and I arrived in the city on Thursday, and immediately purchased this pass. I assumed that it would last us until our Sunday departure:

  • Thursday to Friday — 1 day
  • Friday to Saturday — 2 days
  • Saturday to Sunday — 3 days

I was using zero-based counting, assuming that Thursday was day 0.

And, again, I was wrong. As is made rather clear on the STM explanation of the pass, it’s good for “3 consecutive days” of travel, meaning that, as with Porto and its zones, you start counting with 1.

I realized the folly of my ways when Sunday arrived and my mother, who had purchased her own 3-day pass on Friday, was happily accepted with a “green” signal when we got on the bus where Oliver and I, following behind her, were rejected with a “red” signal.

So you’d think I’d be safe simply assuming that one-based numbering is universal and using that as my default.

But it’s not.

Next week I’m spending 6 days in New Hampshire at Yankee Publishing and I pre-loaded a Roam Mobility prepaid SIM card up in anticipation. Roam’s text + talk + data plan is billed by the day. I reasoned, knowing the error of my earlier ways, that because I’d be in New Hampshire for 6 days, I needed to purchase 6 days worth of service.

But I was wrong.

Roam uses zero-based day-counting for its system: a “day” in their world is a 24 hour period starting from the hour of activation. So I only needed “5 days” of service to cover the period from Sunday in the late afternoon to Friday in the late afternoon:

  • Sunday — Day 0
  • Monday — Day 1
  • Tuesday — Day 2
  • Wednesday — Day 3
  • Thursday — Day 4
  • Friday — Day 5

Perhaps the greatest international schism related to zero- vs. one-based numbering has to do with building-floor-numbering.

In Canada we start counting the floors in a building at one: you enter a building from the street and you’re on the first floor.

In Britain, though, and in much of Europe, entering from street level puts you on the ground floor; to get to the first floor you need to walk up one flight of stairs. So if you let a “first floor flat” in London on Airbnb, you’re going to have to walk up a flight of stairs to get to it. And if you let a “fifth floor flat” you’re going to have to walk up five flights of stairs, not four.

The Canadian system is one-based and the British system is zero-based.

And even here in Canada we have difficulty being clear about what floor is what; witness this elevator button pane in Charlottetown City Hall, which should be intuitive and clear but is anything but:

Charlottetown City Hall Elevator Buttons

Given how confusing it can be to use zero-based counting in a one-based system, or vice-versa (believe me, I’ve spent enough time wandering around European buildings looking for friends’ apartments on the wrong floor to know), you’d think there’d be an easier shorthand for communicating about the issue, and that pains would be taken to make it clear, especially in situations where tickets and billing are concerned, which system is in use.

But it seems to be assumed that we should know this intuitively, and we don’t have easy shorthand for communicating about it: I had to call Roam Mobility last week and ask something along the lines of “if I’m arriving in the US on Sunday and leaving on Friday, do I need to purchase 5 days of service or 6?” The agent I spoke to was obviously used to answering questions like this, which adds credence to the notion that this should be made clearer on the Roam website. For example, they could change their purchase widget from:

Current widget

to this, adding the expiration date so that it’s clear what “5 days” means:

Change the widget to show expiration date and time.

As it is we’re all forced to greet each new system, and each new jurisdiction, assuming that they could start counting at either zero or one, and to discover through experience — or the threat of arrest at the hands of the transit cops — which it is.


Oliver B's picture
Oliver B on June 2, 2016 - 13:05 Permalink

It's relieving to know this messes with other people besides me.

Mike Davies's picture
Mike Davies on June 5, 2016 - 11:25 Permalink

I wholeheartedly concur. I frequently find myself asking 'is this system using ordinal or cardinal numbering?', which if I'm not mistaken is effectively the same problem. It would be too much for everyone to explicitly state the basis for their system of numeration, so how are we to avoid these pitfalls?