1 Son düzenleyen, konuka (14.12.2014 14:12:46)

Konu: programcıda yanlış istedik diyememişler

Youtube “Gangnam Style" görüntülenme tikinin 2,147,483,647 sonra artmadığını diye 4 bitlik saklama alanında +- en fazla bu kadar olur diye açıklamış.
Programcıya adam gibi kaç tik alınabileceğini söylememişler, o da integer alanı yerine biginteger almamış veya saymaya - den başlatmamış....

http://www.economist.com/blogs/economis … ubecounter

Exact-number data types that use integer data.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.
Data type    Range      Storage
bigint         -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)      8 Bytes
int              -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)                                          4 Bytes
smallint      -2^15 (-32,768) to 2^15-1 (32,767)                                                               2 Bytes
tinyint          0 to 255                                                                                                    1 Byte

The Economist explains
How “Gangnam Style” broke YouTube’s counter
Dec 10th 2014, 23:50 BY G.F. | SEATTLE

THE popularity of the “Gangnam Style” video by Psy, a South Korean pop star, is beyond all reckoning. Or at least it was, until a change was made in YouTube's programming. The singer’s video was poised to exceed 2,147,483,647 plays, at which point YouTube would have been unable to count any higher. But the boffins made some tweaks, and now Psy is safe until his rousing anthem passes over nine quintillion views: 9,223,372,036,854,775,808 to be precise. Why couldn’t YouTube count high enough?

The answer involves zooming in to the very building blocks of computing. All numbers in digital computers, whether stored in silicon memory chips or on rapidly rotating magnetically charged hard-disk platters, are represented in binary digits, or bits. In base ten, numbers are represented using ten digits (zero to nine); in binary, or base two, they are represented using two digits (zero and one). For example, in base ten, the digits of a three-digit number correspond to hundreds, tens and units, and the largest number that can be represented is 999; in binary, the digits of a three-digit number correspond to fours, twos and ones, and the largest number that can be represented is 111 (in other words, seven). An eight-digit binary number, which can represent values from 0 to 255, is called a byte; larger numbers are represented using multiple bytes. Two bytes (or 16 bits) can represent numbers from 0 to 65,535; four bytes (or 32 bits) can represent numbers from 0 to 4,294,967,295; and so on. When YouTube was set up, its programmers decided to use a 32-bit number to store the number of views, which seemed a very reasonable choice at the time.