How 0’s and 1’s in a software can create havoc?

I try to keep learning some coding stuff now and then. And, hence, keep looking for free, interesting courses. My current favorite is Harvard’s CS50. I started it only because it’s the pre-requisite to the AI course from Harvard. Also, it goes down to basics and is very interesting! There is one concept – extremely basic – but alarmingly destructive, that was shared in one of the lectures. Bits, bytes and the mysterious case of integer overflow.

Be it Boeing plane needing restart after 248 days of power on, Mario randomly dying after 127 levels resetting the level to 000, Y2K system end of the world hype, Whatsapp hackers controlling devices during Video calls and many more…all somehow were related to this concept.

Bits, Bytes, and the Mysterious Case of Integer Overflow

Have you ever wondered how computers store and process numbers? It all comes down to bits and bytes—the fundamental building blocks of digital information. But sometimes, these tiny building blocks can cause some big problems. One such issue is integer overflow, which has led to software failures, system crashes, and even some of history’s most infamous glitches.

Bits and Bytes: A Quick Refresher

Computers don’t understand words or images like we do—they see everything in binary: a series of 1s and 0s. A bit (short for binary digit) is the smallest unit of data in computing and can hold a value of either 0 or 1. A byte consists of 8 bits, which allows for 256 different combinations (from 00000000 to 11111111). Literally, everything is stored as 0 and 1.

When dealing with numbers, computers use these bits and bytes to represent integers. However, since a fixed number of bits is allocated for each integer, there’s a limit to how large the number can be. This is where integer overflow comes in.

What is Integer Overflow?

Imagine you have a car’s odometer that only goes up to 99,999 miles. The moment you hit 100,000 miles, it rolls back to 00000. That’s exactly how integer overflow works in computers—when a number exceeds the maximum limit that can be stored, it wraps around to a negative or unexpected value. This can lead to bizarre software behavior and even critical system failures.

Think about number representations via 2 digits :

  • 00(corresponds to 0),
  • 01(corresponds to 1),
  • 10(corresponds to 2),
  • 11(corresponds to 3)

Since you have only 2 digits, and you have all permutations and combinations used , so representation for 4 will reset to 00, as that’s the only next possible option : to reset back the value to ’00’.

Real-World Disasters Caused by Integer Overflow

  1. The Y2K Bug (Year 2000 Problem)
    • Back in the 20th century, many computer systems stored years using only two digits (e.g., 99 for 1999).
    • When the year 2000 arrived, these systems thought it was 1900 instead, leading to massive software failures in banking, airlines, and government databases.
    • While the worst-case scenarios were averted thanks to frantic coding efforts, it highlighted the risks of integer limitations.
  2. Boeing 787’s Mysterious 248-Hour Reset
    • Boeing’s 787 Dreamliner once had a software bug where, if it remained powered on for 248 consecutive days (or about 2^31 hundredths of a second), an internal system counter would overflow.
    • This caused critical systems to fail, requiring a full restart.
    • Imagine being mid-flight when the system decides it’s time for a reboot—definitely not an ideal situation!
  3. Pac-Man’s Glitchy Kill Screen
    • Classic arcade games like Pac-Man used 8-bit integers to track level numbers, meaning they could only count up to 255.
    • When players reached level 256, the game’s memory overflowed, displaying a split-screen mess of jumbled characters and making progress impossible.
    • This became known as Pac-Man’s kill screen, a legendary example of integer overflow in gaming.
  4. The Year 2038 Problem (The Next Y2K?)
    • Many older systems use a 32-bit integer to store time as the number of seconds since January 1, 1970 (known as the Unix Epoch).
    • But here’s the catch: on January 19, 2038, this number will exceed its maximum value (2,147,483,647 seconds), causing systems to reset to 1901 or crash altogether.
    • If left unaddressed, this could affect financial transactions, embedded systems, and even infrastructure like power grids and transportation networks.

Why Does This Keep Happening?

Many of these problems arise because software is built with assumptions about numbers and time that don’t account for growth or longevity. Engineers often design systems to last only a few decades, and when those limits are reached, chaos can ensue.

Final Thoughts

Integer overflow might seem like a geeky, technical issue, but it has had real consequences in history. From crashing airplanes to breaking video games, these tiny numbers hold a surprising amount of power. With upcoming events like the Year 2038 problem and AI revolution, our digital world problems would be interesting.

So next time you see a weird glitch in a game or hear about a software bug, remember: it could just be the ghosts of bits and bytes, struggling to keep up with the future! 🙂

Leave a comment