Bits & Bytes

The Restart of Time

Is the Unix Epoch due for a reset?

Ryo Light
3 min readJun 24, 2021

Prerequisites:

  • A basic knowledge of bits, bytes, and words

Refresher:

  1. Intro to Binary Numbers | CSAnim
  2. Intro to Binary Integers | Aidi Rivera
Photo by Aron Visuals on Unsplash

Have you ever asked yourself how time is represented in a computer? And how about whether we’re on the verge of running out of bits to store said time?

Fantastic, then let’s get to the bottom of it!

The Representation of Time

We’ll start with the simpler question, the representation of time in bits.

In computer science, we generally record & store time in milliseconds relative to January 1st, 1970, i.e. the start of the Unix Epoch.

Knowing this, you may find yourself wondering:

Well there are 1000 ms in EVERY second and that has to add up fast. We’re already 50 years past the epoch and that’s a lot of milliseconds! Won’t we run out of bits soon, say in a few decades?

Good news is that we’ve little to worry about and even better, I’ll show you why.

The Magnitude of Time in Millis

Now that we know how time is stored, let’s continue by getting a feel for the scale of milliseconds.

  • 1 sec = 1,000 ms (Cool, looks manageable)
  • 1 min = 60 sec = 60,000 ms (Well that was a big jump ^_^’)
  • 1 day = 1,440 min = 86,400,000 ms (Spongebob, you’re spending all me bits!)
  • 1 year = 365 days = 31,536,000,000 ms (…!!!) ヽ(ಠ_ಠ)ノ

Hmmmmm… so ~32 billion milliseconds go by each year.

Seems like a rather large value for a single year, doesn’t it?

The Magnitude of the Container

Now we’ll get a feel for the scale of our data types which will hold the milliseconds elapsed since a given date.

While word sizes can be 32 or 64 bits, we forgo one bit in order to represent negative values, i.e. time before the Unix epoch.

Signed Max Values

  • 32-bit word: 2³¹ = 2,147,483,648 ≈ 2.15E9
  • 64-bit word: 2⁶³ = 9,223,372,036,854,775,808 ≈ 9.2E18

Since the number of milliseconds in a year is 3.15E10, we’ve already surpassed the size of a 32-bit word. But there’s still hope!

A 64-bit word can represent a value several magnitudes higher than a year of milliseconds, i.e. 10¹⁸ vs 10¹⁰, but just how many years?

9,223,372,036,854,775,808 ms ÷ 31,536,000,000 ms/yr = 292,471,208.68 years

A 64-bit word can represent time a colossal 2.9E8 years to either end of a given date, i.e. ~290 million years in the past or future.

So maybe if humans are still around by 268,435,456 AD (2²⁸), we’ll need a v2 of the Unix epoch, the restart of time.

Perhaps we’ll decide to reset at a happier number, e.g. 250,000,000 AD.

I imagine by then our processors will support much higher word sizes, e.g. x256, x2048, and beyond. I personally can’t fathom practical uses of word sizes over 128-bits aside from cryptography. However, intergalactic conquest & expansion may prove this point moot.

In any case, we can put our minds at ease. The restart of time of time won’t happen on our watch. ⌚️

Until Next Time,
Pulkit

--

--

Ryo Light
Ryo Light

Written by Ryo Light

Software Architect | Crypto Linguist | Hot Chocolate Enthusiast

No responses yet