Did you know that in 2014, a radar data processing system used by the regional air traffic control facility serving Southern California failed after running continuously for an extended period? The failure caused hundreds of flights to be delayed by 1 to 3 hours, and some were even canceled. Later, it was revealed that the failure happened because of a very small software bug involving a signed integer overflow.
But what is a signed integer overflow?
Computers store numbers in binary. Most older computers were/are still using 32-bit systems. That means that the biggest number a 32-bit unsigned integer can store is a binary value with 32 1's next to each other. That number is:
232−1=4,294,967,295
However, computers need to store negative numbers as well. So, computer scientists in the 1960s came up with a solution. Using the most significant bit to store the sign. If it is 0, that is a positive number; if it is 1, that is a negative number. This is called a 32-bit signed integer. To be able to read a negative number, you have to invert all the bits and add 1.
Example:
​→ 11111111=−1→ 00000001=1​
Therefore, we can now represent negative numbers, with a small caveat. The biggest positive number we can go up to now is 31 1's next to each other. So, our range became:
−2,147,483,648 to 2,147,483,647
An integer overflow happens when a number exceeds the maximum value the data type can store. Which basically means that a 32-bit signed integer cannot exceed 2,147,483,647.
After the investigation, authorities found that the system was keeping track of time using a 32-bit signed integer, counting milliseconds. Which means the system was going to crash after:
2,147,483,647 ms≈24.85 days
They knew about this, but their solution was basically restarting the system. However, this time they forgot. This was a good lesson for those programmers not to keep track of time using a 32-bit signed integer.
A nice note: A 64-bit signed integer can run for 292 million years (counting milliseconds) without crashing.
263−1=9,223,372,036,854,775,807 ms≈292,471,208 years
I first read about this story in the book Humble Pi by Matt Parker. I strongly recommend it to everyone interested in math.