Humble Pi
Page 3
So the system was recalibrated to count the number of whole seconds since the start of 1970. This number was stored as a signed 32-digit binary number which allowed for a maximum of 2,147,483,647 seconds: a total of over sixty-eight years from 1970. And this was put in place by members of the generation who in the sixty-eight years leading up to 1970 had seen humankind go from the Wright Brothers inventing the first powered aeroplane to humans dancing on the Moon. They were sure that, by the year 2038, computers would have changed beyond all recognition and no longer use Unix time.
Yet here we are. More than halfway there and we’re still on the same system. The clock is literally ticking.
Computers have indeed changed beyond recognition, but the Unix time beneath them is still there. If you’re running any flavour of Linux device or a Mac, it is there in the lower half of the operating system, right below the GUI. If you have a Mac within reach, open up the app Terminal, which is the gateway to how your computer actually works. Type in date +%s and hit Enter. Staring you in the face will be the number of seconds that have passed since 1 January 1970.
If you’re reading this before Wednesday, 18 May 2033 it is still coming up on 2 billion seconds. What a party that will be. Sadly, in my time zone, it will be around 4.30 a.m. I remember a boozy night out on 13 February 2009 with some mates to celebrate 1,234,567,890 seconds having passed, at just after 11.31 p.m. My programmer friend Jon had written a program to give us the exact countdown; everyone else in the bar was very confused why we were celebrating Valentine’s Day half an hour early.
Celebrations aside, we are now well over halfway through the count-up to destruction. After 2,147,483,647 seconds, everything stops. Microsoft Windows has its own timekeeping system, but MacOS is built directly on Unix. More importantly, many significant computer processors in everything from internet servers to your washing machine will be running some descendant of Unix. They are all vulnerable to the Y2K38 bug.
I don’t blame the people who originally set up Unix time. They were working with what they had available back then. The engineers of the 1970s figured that someone else, further into the future, would fix the problems they were causing (classic baby-boomers). And to be fair, sixty-eight years is a very long time. The first edition of this book was published in 2019 and, occasionally, I think about ways to future-proof it. Maybe I’ll include ‘at the time of writing’ or carefully structure the language to allow for things to change and progress in the future so that it doesn’t go completely out of date. You might be reading this after the 2 billion second mark in 2033; I’ve allowed for that. But at no point do I think about people reading it in 2087. That’s sixty-eight years away!
Some steps have already been taken towards a solution. All the processors which use 32-digit binary numbers by default are known as 32-bit systems. When buying a new laptop, you may not have paused to check what the default binary encoding was, but Macs have been 64-bit for nearly a decade now and most commonly used computer servers will have gone up to 64 bits as well. Annoyingly, some 64-bit systems will still track time as a signed 32-bit number so they can still play nicely with their older computer friends but, for the most part, if you buy a 64-bit system it will be able to keep track of time for quite a while to come.
The largest value you can store in a signed 64-bit number is 9,223,372,036,854,775,807, and that number of seconds is equivalent to 292.3 billion years. It’s times like this when the age of the universe becomes a useful unit of measurement: 64-bit Unix time will last until twenty-one times the current age of the universe from now. Until – and assuming we don’t manage another upgrade in the meantime – on 4 December in the year 292277026596CE all the computers will go down. On a Sunday.
Once we live in an entirely 64-bit world, we are safe. The question is: will we upgrade all the multitude of microprocessors in our lives before 2038? We need either new processors or a patch that will force the old ones to use an unusually big number to store the time.
Here is a list of all the things I’ve had to update the software on recently: my light bulbs, a TV, my home thermostat and the media player that plugs into my TV. I am pretty certain they are all 32-bit systems. Will they be updated in time? Knowing my obsession with up-to-date firmware, probably. But there are going to be a lot of systems that will not get upgraded. There are also processors in my washing machine, dishwasher and car, and I have no idea how to update those.
It’s easy to write this off as a second coming of the Y2K ‘millennium bug’ that wasn’t. That was a case of higher level software storing the year as a two-digit number, which would run out after ninety-nine. Through a massive effort, almost everything was updated. But a disaster averted does not mean it was never a threat in the first place. It’s risky to be complacent because Y2K was handled so well. Y2K38 will require updating far more fundamental computer code and, in some cases, the computers themselves.
See for yourself
If you want to see the Y2K38 bug in action for yourself, find an iPhone. This may work for other phones, or the iPhone may one day be updated to fix this. But, for now, the built-in stopwatch on the iPhone piggybacks on the internal clock and stores its value as a signed 32-bit number. The reliance on the clock means that, if you start the stopwatch and then change the time backwards, the time elapsed on the stopwatch will suddenly jump forward. By repeatedly moving the time and date on your phone forwards and backwards, you can ratchet up the stopwatch at an alarming rate. Until it hits the 64-bit limit and crashes.
When you really F-22 it up
How hard can it be to know what date it is? Or will be? I could safely state that 64-bit Unix time will run out on 4 December 292277026596CE because the Gregorian calendar is very predictable. In the short term, it is super easy and loops every few years. Allowing for the two types of year (leap and normal), and the seven possible days a year can start on, there are only fourteen calendars to choose from. When I was shopping for a 2019 calendar (non-leap year, starting on a Tuesday), I knew it would be the same as the one for 2013 so I could pick up a second-hand one at a discount price. Actually, for some retro charm, I hunted down one from 1985.
If you care about the sequence of years, the Gregorian calendar loops perfectly every four hundred years after a complete cycle of meta-leap years (the cycle of leaping leap years). So, the day you are enjoying now is exactly the same as the day it was four hundred years ago. You would think this would make it easy to program it into a computer. And it is, if the computer stays still. But as soon as the computer can move, it starts to get complicated.
Mistake from the internet
GOOD LUCK EVERYONE!!! This year, December has 5 Mondays, 5 Saturdays and 5 Sundays. This happens once every 823 years. This is called money bags. So share it and money will arrive within 4 days. Based on Chinese Feng Shui. The one who does not share will be without money. Share within 11 minutes of reading. Can’t hurt so I did it. JUST FOR FUN.
This is one of many popular internet memes which claim that something happens only every 823 years. I have no idea where the number 823 came from. But, for some reason, the internet is rife with claims that the current year is special and that this specialness will not be repeated for 823 years.
Now you can safely reply and say that nothing in the Gregorian calendar can happen less frequently than once every four hundred years. JUST FOR FUN.
And, given that there are only four possible month lengths and seven different starting days, there are actually only twenty-eight possible arrangements for the days of a month. So stuff like this actually happens every few years. (Not based on Chinese Feng Shui.)
In December 2005 the first F-22 Raptor fighter aircraft came into service. To quote the United States Air Force (USAF), ‘The F-22 is a first-of-a-kind multi-mission fighter aircraft that combines stealth, supercruise, advanced maneuverability and integrated avionics to make it the world’s most capable combat aircraft.’ But, to be fair, this was taken from the budget statement in which the air force was
trying to justify the expense. The USAF ran the numbers and estimated that, by 2009, the cost of getting each F-22 in the air was $150,389,000.
The F-22 certainly did have some really integrated avionics. In older aircraft, the pilot would be physically flying the plane with controls that used cables to raise and lower flaps, and so on. Not the F-22. Everything is done by computer. How else can you get advanced manoeuvrability and capable combat? Computers are the way forward. But, like planes, computers are all well and good – until they crash.
In February 2007 six F-22s were flying from Hawaii to Japan when all their systems crashed at once. All navigation systems went offline, the fuel systems went and even some of the communication systems were out. This was not triggered by an enemy attack or clever sabotage. The aircraft had merely flown over the International Date Line.
Everyone wants midday to be roughly when the sun is directly overhead: the moment when that part of the Earth is pointing straight at the sun. The Earth spins towards the east, so, when it is midday for you, everywhere to the east has already had midday (and has now overshot the sun), while everywhere to the west is waiting for their turn in the noon sun. This is why, as you move east, each time zone increases by an hour (or so).
But this has to stop eventually; you can’t go forward in time constantly while travelling east. If you were to magically lap the planet at a super-fast rate, you wouldn’t get back to where you started and find it was a complete day in the future. At some point, the end of one day has to meet, well, the day before it. By stepping over the International Date Line, you go back (or forward) a complete day in the calendar.
If you’re finding it hard to get your head around this, you’re not alone. The International Date Line causes all sorts of confusion and whoever was programming the F-22 must have struggled to work it out. The US Air Force has not confirmed what went wrong (only that it was fixed within forty-eight hours), but it seems that time suddenly jumped by a day and the plane freaked out and decided that shutting everything down was the best course of action. Mid-flight attempts to restart the system proved unsuccessful so, while the planes could still fly, the pilots couldn’t navigate. The planes had to limp home by following their nearby refuelling aircraft.
Modern fighter jet or ancient Roman rulers: sooner or later, time catches up with everyone.
Calen-duh
Programmer Nick Day emailed me when he noticed that the calendar on iOS devices seems to break in 1847. Suddenly, February has thirty-one days. And January has twenty-eight days. July is strangely unreliable; December has vanished completely. For the years before 1848, the year headers have disappeared. If you open the default calendar on an iPhone in ‘year view’, it takes only a few seconds of frantic swiping down to see this for yourself.
But why 1847? As far as I can tell, Nick was the first person to spot this, and I could not find an obvious link to Unix time and 32- or 64-bit numbers. But we have a working theory …
Apple has more than one time available at its disposal and sometimes uses CFAbsoluteTime, that is, the number of seconds after 1 January 2001. And if CFAbsoluteTime is stored as a signed 64-bit number with some of the digits dedicated to decimal places (a double-precision floating-point value), there would be only 52 bits of space for the integer number of seconds.
The largest possible number held in a 52-digit binary number is 4,503,599,627,370,495, and if you count back that many microseconds (instead of seconds) from 1 January 2001, you land on Friday, 16 April 1858 … which could be why it breaks around this date … maybe. Well, it’s the best we’ve got!
If any Apple engineers can provide a definite answer, please get in touch.
TWO
Engineering Mistakes
A building doesn’t have to fall down to count as an engineering mistake. The building at 20 Fenchurch Street in London was nearing completion in 2013 when a major design flaw became apparent. It was nothing to do with the structural integrity of the building; it was completed in 2014 and is a perfectly functioning building to this day, and was sold in 2017 for a record-breaking £1.3 billion. By all measures, it’s a successful building. Except, during the summer of 2013, it started setting things on fire.
The exterior of the building was designed by architect Rafael Viñoly to have a sweeping curve, but this meant that all the reflective glass windows accidentally became a massive concave mirror – a kind of giant lens in the sky able to focus sunlight on a tiny area. It’s not often sunny in London, but when a sun-filled day in summer 2013 lined up with the recently completed windows, a death heat-ray swept across London.
Okay, it wasn’t that bad. But it was producing temperatures of around 90°C, which was enough to scorch the doormat at a nearby barber’s shop. A parked car was a bit melted and someone claimed it burned their lemon (that’s not cockney rhyming slang; it was an actual lemon). A local reporter with a flair for the dramatic took the opportunity to fry some eggs by placing a pan in the hotspot.
There was an easy enough fix, though: a sunshade was attached to the building to block the sun’s rays before they could focus on anyone else’s lemon. And it’s not as if this freak alignment of reflective surfaces could have been predicted in advance. It had never happened to a building before. At least, not since the same thing happened at the Vdara Hotel in Las Vegas in 2010. The curved glass front of the hotel focused sunlight and burned the skin of hotel guests lounging by the pool.
But can we reasonably expect the architect of 20 Fenchurch Street to have known about a hotel out in Las Vegas? Well, the Vdara Hotel was also designed by Rafael Viñoly, so we could probably expect some information flow between the two projects. But, for the record: there are always more factors at play. For all we know, Viñoly was hired specifically because the developers wanted a curved, shiny building.
Even without a previous building having set something on fire, however, the mathematics of focusing light is very well understood. The shape of a parabola – that ubiquitous curve from whenever you had to graph any variation on y = x2 at school – will focus all directly incoming parallel light on to a single focal point. Satellite dishes are parabola-shaped for this exact reason; or rather they are paraboloids – a kind of 3D parabola.
If the light is a bit misaligned, a sufficiently parabolic shape can still direct enough of it into a small enough region for it to be noticeable. There is a sculpture in Nottingham, the Sky Mirror, which is a shiny, paraboloid-like shape, and local legend has it that it has been known to set passing pigeons on fire. (Spoiler: it probably hasn’t.)
Bridges over troubled maths
When looking at humankind’s relationship with engineering disasters, bridges are a perfect example. We’ve been building them for millennia, and it is not as simple as building a house or a wall. The potential for mistakes is far greater; they are, by definition, suspended in the air. On the up side, they can have a massive impact on the lives of people near them, bringing otherwise separated communities together. With such potential benefits, humans have always been pushing the limit of what is possible with bridges.
There are plenty of modern examples of bridges going wrong. Famously, when London’s Millennium Bridge was unveiled in 2000, it had to be closed after only two days. The engineers had failed to calculate that people walking on it would set the bridge swinging. In order to give the bridge a very low profile, it was effectively ‘side suspended’, with the supports next to, and sometimes below, the walking platform of the bridge.
Most suspension bridges have supporting steel cables which hang down from above the business part of the bridge. In the ongoing pursuit of a low profile, the steel cables of the Millennium Bridge dip only about 2.3 metres. So, instead of being suspended from a rope hanging above like someone abseiling down a cliff, the ropes were pulled almost straight and held the bridge up, in effect functioning more like a tightrope. The steel ropes have to be very tight: the cables carried a tension force of about 2,000 tonnes.
Much like a guitar str
ing, the more tension in a bridge, the more likely it is to vibrate at higher frequencies. If you gradually decrease the tension in a guitar string, the note it plays will get lower, until the string becomes too slack to play any note at all. The Millennium Bridge had been accidentally tuned to around 1 Hertz. But not in the normal up-and-down direction; it wobbled from side to side.
To this day, the Millennium Bridge is known to Londoners as The Wobbly Bridge. Any major building in London is quickly given a nickname. Directions to The Onion could involve walking past The Gherkin and going left at The Cheese Grater. (Yes, they are all buildings.) Number 20 Fenchurch Street was The Walkie Talkie – until everyone unanimously switched to The Walkie Scorchie. The Millennium Bridge continues to be The Wobbly Bridge, even though it only wobbled for two days.
But I love the way the nickname gets the direction completely right. It is not The Bouncy Bridge, even though that is a catchier name. It is The Wobbly Bridge. The bridge did not bounce up and down at all; it, unexpectedly, swung from side to side. Engineers have a lot of experience in stopping bridges from bouncing, and all the calculations were spot on for vertical movement. But the engineers who designed the Millennium Bridge underestimated the importance of lateral movement.
The official description for what went wrong was ‘synchronous lateral excitation’ from pedestrians. It was the people walking on the bridge which caused it to wobble. Getting something as massive as the Millennium Bridge to start to wobble using brute force is a near-impossible challenge for a bunch of pedestrians. Except this bridge was accidentally tuned to make it easy. Most people walk at about two steps per second, which means their body swings side to side once per second. A human walking is, for all bridge intents and purposes, a mass vibrating at 1 Hertz – which was the perfect rate to get the bridge wobbling. It matched one of the bridge’s resonant frequencies.