You-Tube learns on integer overflow, Gangnam Style! #December_2014

You-Tube learns on integer overflow, Gangnam Style! #December_2014

March 21, 2019 0 By NewsTakers

Generalising, N bits can store 2 N different values.
Therefore the biggest number you can fit into 32 bits is 2 32 –1, or 4,294,967,295.
So, in 32 bits of signed number, there is one bit for the sign, and 31 bits available for counting, meaning that you can represent 2 32 different numbers ranging from -2 31 up to 2 31 –1.
In other words, if any YouTube video should ever rack up 2,147,483,647 views, it will have hit its limit.
(Why did Google use signed numbers?
How do you watch a video a negative number of times?)
Arbitrary limits considered harmful Is a 2G limit in this context actually a problem?
Google’s 17-character restriction on Android passwords is a ridiculous limit; Microsoft’s 16 character Outlook.com passwords are even worse; but as arbitrary limits go, two billion YouTube views feels as though it ought to be more than enough.
It’s easy just to say, as Google now admits , “We never thought a video would be watched in numbers greater than a 32-bit integer.”
Even daily human tasks can clock up surprisingly large counts: as we reported recently, the South African Navy has now fired its 300-year-old Noon Guns in Cape Town on more than 65535 days in the past two-and-a-bit centuries of unbroken noonday gunning.

In cases where even larger numbers are needed—calculations involving the many trillions of dollars of the U.S. GDP, for example, or astronomical measurements—it’s possible to use 64-bit integers instead. The memory footprint for each of these data points will be twice as heavy, but they can then be used to store far higher numbers. So what’s the new 64-bit limit? 9,223,372,036,854,775,808. And that, for thos…

Source link