Epoch Article, Part 2

This is the second part of a two-part post about measuring time. Part one is here.

Last time we discussed our familiar calendar, and the conclusion was that it is really messy. Well, then we should maybe make a better one?

This idea is much less crazy than it sounds. Of course, it would be very hard, if not impossible, to persuade the entire world’s population to switch to a better calendar. But there is point in having a special calendar to be used by tech people in solving problems that are hard enough even without all these leap years.

In the simplest possible calendar, time is a single real number. This number indicates how many [time units] have elapsed since [reference date]. Easy, right? Well, as you have probably already guessed, the answer is “wrong”.

Julian date

The first people to adopt such calendar were astronomers. Their apparent lack of imagination resulted in the calendar being called Julian date. It is the number of days since noon GMT January 1, 4713 BC. Dealing with Julian date is simple; the only problem arises when one wants to convert between Julian and ordinary dates. This is done by using two extremely complex formulas, the more frightening of which is shown below:

There is even a joke among programmers that no living person understands the meaning of these coefficients.


USS Enterprise near Saturn

Up to this point, I successfully avoided speaking about fictional calendars. However, now I can’t resist writing a few words about Stardate.

Stardate is used by humans and other intelligent species in the Star Trek universe. It is always a single real number, but other than that, the format of Stardate varies wildly between different series and movies. Let’s first focus on Stardates in The Original Series.

The first episode starts with Kirk saying “Captain’s Log, Stardate 1513.1”. The most interesting question is whether this is a real date that can be converted to something else or just a random number. We could find the answer by browsing Wikipedia or Memory Alpha, but that’s not how mathematicians do it. Instead, let’s compare the number of digits in Stardate and ordinary date.

Stardate has 5 digits, that’s easy. Date in Gregorian calendar has two digits for day, but the first one doesn’t go all the way up to nine, so it’s like half a digit. Month is also two digits, but the first one doesn’t really count because it is usually zero. Using the same logic, we can say that the year has 3½ digits. In total, we have 6 digits. Therefore, Stardate either has very low precision or, more likely, it is made up. Memory Alpha confirms that Stardates were indeed chosen arbitrarily.

Note: If you are in high school learning logarithms, try doing your homework like this. Your Math teacher will love it.

Since I am writing this post only days after Star Trek Beyond came out, I should probably talk about Stardate as it appears in the newest Star Trek movies. There is not much to speak about, actually: the integer part is the year, and the fractional part is, quite counterintuitively, the number of days since the start of a year. For example, 2233.04 means the fourth day of 2233.

Unix time

Let’s get back to serious business. Single-number calendars are currently most widely used by computers. It would be great if all programmers agreed on one universal calendar, but they instead created a multitude of incompatible ones via the following scheme:

How standards proliferate

The only calendar that stands out from the rest is Unix time, used by all Unix-like operating systems. It uses the reference date (by the way, it is also called epoch) of January 1, 1970. The time increments by one every second, which is convenient, because it allows to drop the fractional part unless you need very high precision. Unix was not designed for such high precision, so it stored the time in a signed 32-bit integer.

Signed 32-bit integer can store a value between -231 and 231-1 inclusive. If you assign the highest possible number to a 32-bit variable and then try to increment it, one of two things will happen:

  1. You will get an error.
  2. The number will “wrap around”, and you will get -231. This option is much more likely than the first one.

In either case, it is obvious that everything will break when the Unix time overflows. But when will this happen?

A relatively useless chart

The chart above suggests that 231 seconds are just under one century, so the overflow should occur a bit before 2070. More precisely, it will happen at 03:14:07 UTC January 19, 2038.

Fortunately, most systems manufactured today use 64-bit integers, so they should avoid all problems… except they don’t. Not long ago it turned out that iPhone stored dates in an unsigned 64-bit integer, which can only manipulate numbers between 0 and 264-1. When the phone needed to deal with a date before 1970, it wrapped around and broke down.

There is of course more to Unix time than overflow and underflow errors. For example, every time a leap second is introduced, programmers have a massive headache.

Also, having a birthday on January 1, 1970 can probably be as bad as having surname Null.

Other systems

As I mentioned before, Unix time is not the only time standard used in computing. You can see a relatively complete list here.


Fortunately, most programming languages have a built-in date type, which takes care of more or less all issues that may arise. Use it; don’t try to make you own time libraries, because that way lies madness.

Live long and prosper.

Posted in Uncategorized | 1 Comment

Epoch Article, Part 1

This is the first part of a two-part post about measuring time. Part two is here.

In Physics class, we learn how to measure different things. We measure length, area, volume, velocity, force, energy, momentum, etc. using stone age tools and, in most complex cases, even primary school math. Then we express the values in SI units, perhaps with some prefix, or in different units entirely, in which case everyone is confused and outraged.

However, there is something we learn to measure long before we hear the word “physics”. This thing is time. As small children, we get a seemingly firm grasp of clocks and calendars, and then, when we grow up, we regard time as something simple and not even worth talking about.

In this article, I want to give a hint that dealing with time is actually extremely complicated, or at least much more complicated than high school Physics curriculum.

From second to day

A second is one of the base SI units. Like all other base units, it is defined in a bizarre and counterintuitive manner, namely as “the duration of 9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom”. I will not comment on this definition, since I don’t really understand it myself.

Next, there is a minute, which is 60 seconds, right? Wrong. Since the Earth does not spin at a perfectly constant speed, sometimes it is neccessary to insert a leap second, which essentially makes an unlucky minute 61 seconds long. When a leap second is inserted, time goes like this:

… 23:59:58 23:59:59 23:59:60 00:00:00 00:00:01 …

To make things worse, leap seconds are added at irregular intervals.

60 minutes make an hour, and 24 hours make a day, and here we don’t encounter any difficulties… although, wait, we do. But let’s put them in the next section.

Time zones

Since the Sun rises and sets at different time depending on the longtitude, people created time zones. We could have just divided the Earth into 24 equal slices and call them time zones UTC-12 to UTC+11 or UTC-11 to UTC+12 if you prefer. It is a great idea, except everybody disliked it. Small countries didn’t want to be split between two time zones and so on. As a result, the map of time zones became surprisingly complex.

Map of time zones

There is one more strange thing about this map: time zones are not just weirdly shaped, there are also too many of them. Let’s look at the list. There are 39 time zones, some of which seem really redundant, like UTC+12:45.

In addition, time zones are not constant. Countries change them every now and then. For example, Samoa once decided to hop to the other side of the International Date Line and therefore skipped an entire day.

And then there is West Bank, where Israeli and Palestinian people live in accordance with different time zones…


What’s next? In many countries, time is shifted one hour forward in spring and one hour backward in autumn, so that people’s waking hours are better aligned with the day / night cycle. There are lots of problems with this.

Firstly, countries shift clocks on different days. Secondly, countries in the Southern hemisphere have spring and autumn at the wrong time, so they enable DST when everybody else disables it. And thirdly, there are countries that think there is not enough confusion as is, so they add even more problems.

Russia, in which I happen to live, is one such country. Before every spring and autumn, some important guys toss a coin call random() ask the god of time measurement do the evaluation of possible economic gains and decide whether we should shift clocks. What I don’t understand is why they are getting a different answer every time. Makers of computers and smartphones tried to keep up, but apparently gave up on it. My iPhone is currently one hour ahead of real time.

From day to year

Let’s move to longer periods of time. A month can have 28 to 31 days, and the distribution of long and short months seems pretty random. Or at least it’s close enough to random that most people have trouble remembering it.

A stick man from xkcd tries to figure out how long October is

Actually, there is some logic behind this distribution, but it is a topic for a different article. Anyway, compared to what I covered in the previous sections, this is a minor annoyance. The big problem comes when you get to February, which becomes one day longer in leap years.

Leap years exist because the year does not have an integer number of days. It is very close to 365¼ days, and that’s why about one in four years is leap. Unfortunately, the number of days in a year is slightly different from 365¼, and therefore the Julian calendar, where exactly every fourth year was leap, didn’t work out well. People switched to Gregorian calendar, which has the following rules for deciding what years should be leap:

  • A year divisible by 4 is leap.
  • Well, unless it’s also divisible by 100, in which case it’s not leap.
  • But if the year is also divisible by 400, it will be leap.

So far, this is not too difficult to remember and/or implement in an app. There is one issue, though: remember how I said that we switched to a refined calendar? Of course, every country did this at a different time, and some countries did it in really weird ways.

And beyond

Years seem to be the easiest thing about dealing with time. Sure, there was no year 0, but it was long ago, and it doesn’t take more than a couple lines of code to implement anyway. Except this, years have no surprises for us, right? Wrong.

In the 20th century, people thought that the year 2000 is unimaginably far away and not worth thinking about. Hence, many systems stored only the last 2 digits of the year. As 2000 approached, programmers had to change all their code to accept four-digit years. As it always happens with this sort of thing, redoing took much more effort than making everything normal in the first place would. Also, some people apparently forgot to fix it at all.

Sign displaying year 1900

Some guys propose that we go one step further and switch to five-digit years right away. If I will be still maintaining this blog 8000 years later, I will surely write a follow-up post explaining if they were right or not.

One thing to consider

Did you know that our calendar isn’t the only one? Just imagine that we multiply all the problems presented here by the number of calendars used in the world. I must say that my imagination is not even nearly good enough for this.

Tom Scott’s video

Tom Scott once made a video about the same subject, so if you want to learn more, or just like to watch videos embedded in blog posts, here it is:


This was part one. Part two has a lot of interesting stuff about Julian date, Stardate, and Unix time. Check it out!

Posted in Uncategorized | 1 Comment


From now on, I will post photos of my origami models in a special area of my blog. This area is located here. I started things off with a relatively simple yet interesting model, Net of a Tesseract.

When I post new models, I will not put announcements like this one on the front page of my blog. If you would like to see the models, you will have to occasionally visit the origami page.

Posted in Site-related | Leave a comment

Cipher 11

Cipher 11 has been released.

Posted in Ciphers | Leave a comment

On Non-Recoverable Data Loss


Posted in Humour | Leave a comment

Cipher 10

Cipher 10 has been released.

Posted in Ciphers | Leave a comment

New Spaceship Speed in Conway’s Game of Life

In this article, I assume that you have basic familiarity with Conway’s Game of Life. If this is not the case, you can try reading an explanatory article but you will still struggle to understand much of the following content.

The day before yesterday ConwayLife.com forums saw a new member named zdr. When we the lifenthusiasts meet a newcomer, we expect to see things like “brand new” 30-cell 700-gen methuselah and then have to explain why it is not notable. However, what zdr showed us made our jaws drop.

It was a 28-cell c/10 orthogonal spaceship:

An animated image of the spaceship

To explain why this is such a groundbreaking discovery, I should first tell you that Life spaceships can be loosely divided into two categories. Engineered ships are the ones that consist of various small components. They often have adjustable speed. However, the population of tens of thousands to millions of cells causes these spaceships to have no practical value. There is much more incentive in hunting for elementary spaceships, which can be used for complex constructions. They are found using programs such as gfind or WLS. The algorithms behind these programs are beyond the scope of my article, but the important thing is that the search time goes up exponentially as the period of the ship grows. It is most interesting to find spaceships of new speeds, and the number of speeds that low-period ships can have is unfortunately limited:

  Orthogonal Diagonal
c/2 Yes Impossible
c/3 Yes Impossible
c/4 Yes Yes
c/5 Yes Yes
2c/5 Yes Impossible
c/6 Yes Yes
c/7 Yes Yes
2c/7 Yes Impossible
3c/7 No Impossible
c/8 No No
3c/8 No Impossible

This table does not include oblique speeds, which causes little inconvenience because no elementary oblique ships are known.

The table above shows that ships exist for most of possible speeds, and it seems obvious that the speeds for which there are no ships have been searched by numerous people with good knowledge of search programs, powerful computers and lots of patience. As for higher periods, even the smallest searches would take years on modern computers. It appears that low-hanging fruit have been harvested clean during the 46 years of Life research… or, more precisely, it appeared so before zdr’s post.

The idea we all missed is that if the ship is really microscopic, it can be found in reasonable time despite its high period. After zdr boldly went where no man has gone before, Josh Ball set up the corresponding search in gfind and refound the spaceship in a little over an hour. zdr said that their program found it in a matter of 19 seconds.

To be frank, similar event did happen before when the aforementioned Josh Ball pulled loafer out of a hat. However, zdr’s spaceship (which is now called Copperhead, as proposed by muzik) is much more awesome for a number of reasons:

  • Loafer is not so mind-bogglingly high-period.
  • Copperhead was much easier to find, so it is more surprising that nobody found it before.
  • Copperhead’s tail is relatively strong and can interact with other objects without breaking down.

The discovery of a new spaceship speed immediately opened a few new areas of research, which are being explored now.


Aidan F. Pierce came up with a Copperhead synthesis only 10 hours after the completion of the spaceship. The synthesis was inefficient, and a few people discovered better ones. The current best synthesis, made by Chris Cain, requires only 22 gliders. Its repeat time is 375 ticks, which means that a gun can start constructing the second spaceship 375 ticks after the first one. There is a 23-glider synthesis with a better repeat time of 373 ticks.

Incremental 22-glider synthesis of the copperhead

The synthesis can be substantially improved if we find this spaceship crawling out of a random soup. Adam P. Goucher has written a wonderful program called apgsearch, which is perfectly suited for this task. While the current version may be too slow to find a soup in reasonable time, highly anticipated version 3.0 can probably do the trick. Once it is found, it will appear here.


Once the synthesis was complete, building a gun was nothing but corollary-sniping. The first copperhead gun was created by myself, and a video of it is availible here. It was put together in a hurry and is therefore extremely inefficient. In particular, skilled gun builders can spot a silly mistake in the Northeast.

gmc_nxtman then made another gun with an almost optimal period of 376 ticks.


simeks found two eaters for this ship, the better of which is shown below:

A copperhead eater

It is now time to search for a good copperhead-to-something-useful converter. The only existing one is clumsy and slow.


Sawtooths often work by sending a flotilla of fast ships towards a slower ship. The more is the difference in speed, the less is the expansion factor of a sawtooth. Since expansion factor is proportional to how boring the sawtooth is, increasing the speed difference is a good thing. Dean Hickerson collided c/2 standard spaceships with c/10 copperhead to get a sawtooth with expansion factor 6:

Hickerson's sawtooth

He then made another sawtooth with expansion factor 10/3.

Puffers and rakes

Suppose a c/10 flotilla is hit by a glider. The glider turns into loads of mess, but all copperheads somehow survive and move on. The mess releases a glider, which flies into strategically placed second flotilla that is identical to the first one. Gliders continue to bounce back and forth between flotillas leaving mess behind them, and a c/10 puffer is complete! Unfortunately, this cool technique doesn’t work out easily in our case. There are no interesting interactions between a glider and a single copperhead, and it is unclear how one can place two or more copperheads so close to each other that a glider interacts with all of them. Assuming we figure it out, we can try to make a rake by perturbing the mess with copperheads so that it evolves into gliders, but that seems even less likely.

However, all this hand-waving can be turned it real puffers if we find…


Tagalongs are small things that are attached to the back of a spaceship and move with it. Here is an example tagalong, called the Schick engine:

Schick engine pulled by two LWSSs

Finding a tagalong for the copperhead (or two copperheads) will be really nice. We can also try searching for pushalongs, but they are generally rarer.

Other patterns

There are a few other areas of Life exploration where the copperhead can be useful. For example, universal constructors often need to create an elbow still life very far away. It can be done by producing a copperhead, waiting for some time, and then shooting the copperhead down with a LWSS. At the moment I do not see why the copperhead can be better than the loafer in this aspect, but who knows?

Posted in Cellular automata | 30 Comments