Counting Bytes: Is My Hard Drive 320GB or 298GB?
Since we recently wrote about logical data recoveries from hard drives and how they structure information, it seems like a good time to tackle a question our data recovery engineers are frequently asked.
Let’s say you go to the store (or go online) and buy a new 320GB hard drive for $30 or whatever the latest special is on these now basic-level drives. Granted, you're more likely to buy larger drives these days, but just bear with me for this example. You plug the USB connection to your laptop, go to disk manager, and see the drive show up as 298 GB. Or maybe it’s 297.44 GB with a 668 MB Western Digital Smartware virtual CD-ROM partition. Either way, the question is: Where did those extra GB's promised on the box go?
The answer is that kilobytes are counted one way by a computer, and another way by people. A Windows operating system relies on binary and counts in base 2, and the marketing conventions are based on familiar base-10 numbers.
Here’s how it works: Hard drives store data with microscopic patches of metal that are either magnetized or not. One patch is a bit, and together eight of them make a byte.
So, one byte is simply eight tiny switches -- eight 1s or 0s -- resulting in 256 different combinations that can be assigned a value. In ASCII code, for example, the byte “01100101” is the letter “e.” The number “1” in the text we read is “00110001” in binary code.
As you can see, bytes are based in binary – the switches are either on or off, electricity is there or not, the pull of a magnetic field exists or it doesn’t. Ones and zeroes.
Operating systems, such as Windows, live in binary. Numbers expand by the power of 2. Under this system, a kilobyte is defined as 2 to the 10th power (2^10) of bytes, or 1,024 bytes.
The convention for the retail market, on the other hand, is to look at how many bytes there are, divide by a thousand – and bam – there’s the number of kilobytes. The advantage is that people are used to base 10 numbers, and this maintains the traditional definition of kilo. As in, kilo equals one thousand or 10^3.
In the familiar base 10 system, 1 gigabyte = 1,000 megabytes = 1,000,000 kilobytes = 1,000,000,000 bytes. Giga is billion; mega is million; kilo is thousand.
In the binary counting system, though, 1 gigabyte = 2^10 megabytes = 2^20kilobytes = 2^30 bytes = 1,073,741,824 bytes.
The difference between these counting systems explains why an operating system reports the capacity differently from how we’d count bytes in a base 10 system.
Let’s go back to our original example -- the 320 GB hard drive. The box says that there are 320 GB because there are in fact 320,000,000,000 bytes. But an operating system lives in base 2 and defines 1,073,741,824 bytes to be 1 GB. So if you divide 320,0000,000,000 by 1,073,741,824, you get about 298 GB, which is what Windows shows the drive’s capacity to be.
So when you get a new drive and the capacity displayed seems to be less than promised, don't worry. You're still technically getting all the bytes you paid for. It's just counted differently by your computer.
Relevant, over-used joke: There are 10 types of people in this world. Those who know binary, those who don't, and those who weren't expecting this joke to be in base 3.
Originally posted by Jesse Moryn on blog.gillware.com