## Introduction: How to Set a Digital Clock More Accurately

This instructable **is not** a manual about how to set up a digital clock! It's about an accuracy. Let me explain.

I'm sure You have seen a digital clock, the one with 2 digits representing hours, then a colon and another 2 digits representing minutes. If a clock has also 2 digits representing seconds, then an expected accuracy is in range of 1 second what is fully acceptable in daily life and this manual doesn't apply to this.

You have set such a clocks many times in Your life. The procedure is relatively simple:

- Take some reference clock, e.g. time.is
- Set up Your clock to have exact hour and minutes when the reference clock hits some exact minute at 00 seconds. (Usually changing minute resets the seconds to 00)
- Done. From now on Your clock is showing the same hour and minutes as the reference clock, as well as seconds which are not visible. And here is a catch!

But what if I tell You there is a better approach?

Let's start!

## Step 1: What's the Problem?

The problem is with the average accuracy.

Let's say we have set our clock exactly to the reference clock at 12h:00m:00s so they show exactly the same time.

Our clock doesn't have digits representing seconds so it shows only 12:00 (12h:00m).

Let's say we check the time and we see 12:34 (12h:34m) on our clock. What is the real time? How accurate are we? Let's see:

If we are lucky (optimistic), we hit the beginning of the current minute and it is exactly 12h:34m plus some seconds - very accurate.

If we are unlucky (pessimistic), we hit the end of the current minute and it is e.g. 12h:34m:55s. It means that our clock shows the time which is almost 1 minute behind the real time! Very inaccurate.

Because of missing seconds on our clock and how we set our clock, we encounter several problems here:

- Time shown by the clock is not rounded up or down to the closest minute. So even if it is 12h:34m:59s, our clock still shows 12:34 even if we are almost 1 minute behind.
- We are
**always**some fraction of a minute behind the real time - never ahead of it. It is important as some people set a clock a full minute ahead of real time so they will never be late. - By probability, our accuracy will be on average 30s behind the real time. It means that whenever we check the time on our clock, it means (on average, usually) 30s of the current minute have already passed.

Let's put some numbers into the context. We can pick some number of seconds, which we think is still acceptable to be off from the real time. Let's say it is 15s. What is the probability that the time we see on our clock is just a 15s off from the real time? It's 15s / 60s = 0.25

We have only **25%** chance (1 out of 4 times we look at the clock) that the time we see on our clock is acceptably accurate.

## Step 2: Is There a Way for an Improvement?

Yes, there is a way for an improvement.

Our clock is evaluating a mathematical floor function on current time. But we need a rounding function to a closest minute. Good for us, there is a way to do it:

**We need to set our clock to be 30s ahead the real time.**

Let's see how does it work and how can it help us:

We set our clock to be exactly 12h:00m:00s when the reference clock hits 11h:59m:30 (real time). Or the other way: when a reference clock shows 12h:00m:00s (real time) our clock needs to be set up to 12h:00m:**30s**.

Let's analyse our scenario again: later we check the time and the clock shows 12:34 (12h:34m). Let's see what is the accuracy now:

- We hit the beginning of the minute on our clock, e.g. 12h:34m:05s. It means the real time is 12h:33m:35. Because our clock shows 12h:34m, time shown on our clock is 25s ahead of the real time.
- We hit around the middle of current minute on our clock (let's say somewhere between 25s-35s). The real time is around the beginning of the minute 12h:34m:00s - in our example between 12h:33m:55 and 12h:34:05. It means time on our clock (12h34m) is very close to the real time - just +/-05s off.
- We hit the end of the minute on our clock (e.g. 12h:34m:55s). It means the real time is some seconds before 12h:34m:30s (e.g. 12h:34m:25s). In this situation our clock is 25s behind.

In an optimistic scenario, we hit the middle of the current minute so our clock shows the exact time - very accurate.

In a pessimistic scenario, time on our clock is **maximum** 30s behind or **maximum** 30s ahead of the real time. It's not 1 minute off anymore.

The accuracy on average is...**very close to the real time!**

Let's put numbers again. What is the probability that the time we see on our clock is just a 15s off from the real time? It's (15s behind + 15s ahead) / 60s = 0.50

We have now **50%** chance (1 out of 2 times) that the time we see on our clock is acceptably accurate.

How is this possible?

The difference is that in first scenario our clock is mostly behind the real time: it is 59 out of 60s behind and only 1s it shows an exact time. In our second scenario mentioned above, we have shifted the time on our clock by 30s. It means that our clock can be either behind or ahead of the real time. By defining our acceptable accuracy to 15s, we doubled the chances we are within this range - either behind (as in first scenario) or ahead of the real time. It means our range was doubled so it was extended to 30s.

## Step 3: Does It Really Matter?

1 minute is not much...

...unless You are running to catch Your underground/metro train and You see You have 2 minutes. So You stop running and start walking. You think You will reach it. Then just some seconds later, a clock switches to the next minute, but You missed it. You still think You have 2 minutes so You just continue walking - not running.

Yes, it matters.

This problem appears also e.g. in *"next train indicators"* (passenger information system). It usually shows the number of minutes the next train arrives. But it doesn't show seconds. It means we don't know answers to similar questions:

- Is the number of minutes rounded?
- Does it mean:
*"at least 1 full minute and some fraction of a minute left"*? - Or does it say
*"less than a minute left"*?

I'm pretty sure it means the worst scenario: *"less than a minute left"*. We don't know how many seconds do we have till the train arrives. Do we need to run? or walk?

As You see, it's exactly the same problem as setting a clock.

I hope that from now on You will pay attention on how You set a clock or You will check if a particular clock rounds up/down the minutes.

I wish You will never be late :)