YouTube didn't explain how it fixed the problem in any detail, but one fix is fairly easy: YouTube just had to treat the number as an unsigned integer, treating the left-most digit as part of the number rather than as a minus sign. So when Psy got his 2,147,483,648th view, YouTube's server would have thought he had minus 2,147,483,648 views.
The way computers represent negative numbers is too complicated to explain here (Wikipedia has the gory details), but the bottom line is that this counter "wraps around," going from the highest number that can be represented in this format - 2,147,483,647 - to the lowest: negative 2,147,483,648. The largest positive integer you can represent in this format is: What happens when a number gets too big to fit in the space reserved for it? So when Psy got his 2,147,483,648's view, all hell broke loose. That's what Google did in this case, and 2 to the 31st power is 2,147,483,648. So computers often set aside the left-most digit to represent a number's sign (0=positive, 1=negative), leaving 31 digits to represent the number itself. But this has a big disadvantage: you can't represent negative numbers. You can use 32 bits to represent any number from 0 to 4,294,967,295. If YouTube was storing 32 binary digits, then it should be able to count up to 2^32 = 4,294,967,296. That's what happened in this case: the number of Gangnam Style views was so large that it could no longer fit into the space Google had set aside for it. But weird things happen if computers are asked to handle a number so large that it doesn't fit into the space that was set aside for it.
This works great as long as your software is only handling numbers that fit into this format. In this format, decimal 19 would be stored as: One of the most popular ways to store numbers digitally is with a 32-bit binary number. So when they represent a number like 10011 (19 in binary), they pad it out with 0s on the right-hand side. But computers are storing numbers in electronic circuits with a fixed number of digits. Second, when humans write a number like 19, we write however many digits are necessary to represent the number - in this case, the two digits 1 and 9. Decimal 1 is binary 1, then decimal 2 is binary 10, decimal 3 is binary 11, decimal 4 is binary 100, and so forth. First, they use the binary number system, which has two possible values - 0 and 1 - instead of 10.
As we all learned in grade school, you count 1, 2, 3, get to 9, then "roll over" to 10 and count 11, 12, 13, and so forth.Ĭomputers do things differently from humans in two important ways. Human beings count using the decimal number system. To understand YouTube's Gangnam Style problem, you have to understand how computers count. Psy, the man behind "Gangnam Style." (OZAN KOSE/AFP/Getty Images) Why was there a limit to the number of views YouTube could count? Why is the limit such a goofy number? And what did YouTube have to do to fix the glitch? Read on to find out. Without a software upgrade, the "Gangnam Style" counter would have begun showing the song getting negative 2.1 billion views. Because it stores numbers in binary, YouTube was only designed to record up to 2,147,483,647 video views. And that created some headaches for Google's engineers. The video for Psy's song "Gangnam Style" is the most-viewed video in the history of YouTube, with more than 2 billion views.