lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 05.04.2018 08:03, Petri Häkkinen wrote:

      
On 3 Apr 2018, at 23.43, Axel Kittenberger <axkibe@gmail.com> wrote:

Time: The first hour of a day on a digital clock in 24h mode is hour 0 (after midnight). 

Similary we measure our age with completed years, starting with year 0 and many other measuring devices start their units with 0. 
But these are not indices, aren’t they? Time (like distance) is actually a delta measured from some reference point (midnight or birth in these cases). 

Indices would be 1st hour after midnight or 1st year of your life.
I think in a language without pointers, starting counting from 1 is the right way. This way you don’t need to subtract 1 from the upper limit when counting. In practice, the only thing which is slightly more complicated is wrap around when decrementing.

They are also not integers. And I think that is actually the main difference from the examples where counting from 1 is more natural. Natural numbers are often even defined to exclude zero, therefore you need to start with 1.
When it comes to time, you can argue that time is actually a real number and therefore uncountable.

That said, I always get confused by 12 hour clocks as they switch from 11:59 am to 12:00 pm then from 12:59 pm to 1:00 pm and from 11:59 pm to 12:00 am and so on.
So actually wrap around can also be complicated while incrementing.
--
Thomas