Gangnam style viewed so many times it broke youtube's code


Recommended Posts

that will teach them to use a 32-bit signed integer when unsigned would of gotten them double the count, you can't have negative views :rofl: (4,294,967,295 vs 2,147,483,648 positive numbers)

  • Like 3
Link to comment
Share on other sites

that will teach them to use a 32-bit signed integer when unsigned would of gotten them double the count, you can't have negative views :rofl: (4,294,967,295 vs 2,147,483,648 positive numbers)

Simply because the number cannot be negative isn't a very good reason to use an unsigned int. Consider this fairly typical code:

let difference = abs(viewsOfVideo1 - viewsOfVideo2)
This code is broken with unsigned ints because while view counts can't be negative, their difference may be and overflows an unsigned int. You may want to convert to signed integers for the purpose of this calculation but converting between signed and unsigned integers is error-prone in itself.
Link to comment
Share on other sites

I saw a rather large debate on the merits of using a signed int in the first place and the takeaway was that it was a good idea. Doing math with signed ints on unsigned ints causes implicit issues that are easily avoidable by simply using signed ints for everything.

 

I don't think they really expected to be hitting that limit anyways, and it wasn't very difficult to change.

Link to comment
Share on other sites

This topic is now closed to further replies.