# Digital Storage Basics

## Number systems

## The easiest way to understand digital storage begins with something you know: digits and the base-10 or decimal number system. Our base-10 number system likely grew up because we have 10 fingers. A decimal digit is a single place that can hold numerical values between 0 and 9. Digits are normally combined together in groups to create larger numbers. For example, the number 6,357 has four digits. It is understood that in the number 6,357, the 7 is filling the \"1s place,\" while the 5 is filling the 10s place, the 3 is filling the 100s place and the 6 is filling the 1,000s place. So you could express things this way if you wanted to be explicit. 

## The B's Binary, Bits and Bytes

***Binary*** means that something can either be one way or the other.
For example, an answer could be "yes" or "no". An answer could be "true"
or "false".

In digital logic and number systems, binary means that something can
have a value of either 0 or 1.

The word is a shortening of the words \"Binary digIT.\" It refers to the
digits in a binary number. When counting on the binary system, starting
at zero and going through 20, counting in decimal and binary looks like
this:

0 = 0

1 = 1

2 = 10

3 = 11

4 = 100

5 = 101

6 = 110

7 = 111

8 = 1000

9 = 1001

10 = 1010

11 = 1011

12 = 1100

13 = 1101

14 = 1110

15 = 1111

16 = 10000

17 = 10001

18 = 10010

19 = 10011

20 = 10100

Bits are rarely seen alone in computers. They are almost always bundled
together into 8-bit collections, and these collections are called
***bytes***. Similar to how we group eggs into a collection called "a
dozen".

With 8 bits in a byte, you can represent 256 values ranging from 0 to
255, as shown here:

0 = 00000000

1 = 00000001

2 = 00000010

\...

254 = 11111110

255 = 11111111

**Bytes: ASCII**\
Bytes are frequently used to hold individual characters in a text
document. In the **ASCII character set**, each binary value between 0
and 127 is given a specific character. Most computers extend the ASCII
character set to use the full range of 256 characters available in a
byte. The upper 128 characters handle special things like accented
characters from common foreign languages.

You can see the 127 standard ASCII codes below. Computers store text
documents, both on
[disk](http://computer.howstuffworks.com/hard-disk.htm) and in
[memory](http://computer.howstuffworks.com/computer-memory.htm), using
these codes. For example, if you use Notepad in Windows to create a text
file containing the words, \"Four score and seven years ago,\" Notepad
would use 1 byte of memory per character (including 1 byte for each
space character between the words \-- ASCII character 32). When Notepad
stores the sentence in a file on disk, the file will also contain 1 byte
per character and per space.

Try this experiment: Open up a new file in Notepad and insert the
sentence, \"Four score and seven years ago\" in it. Save the file to
disk under the name **getty.txt**. Then use the explorer and look at the
size of the file. You will find that the file has a size of 30 bytes on
disk: 1 byte for each character. If you add another word to the end of
the sentence and re-save it, the file size will jump to the appropriate
number of bytes. Each character consumes a byte.

If you were to look at the file as a computer looks at it, you would
find that each byte contains not a letter but a number \-- the number is
the ASCII code corresponding to the character (see below). So on disk,
the numbers for the file look like this:

> F o u r a n d s e v e n
>
> 70 111 117 114 32 97 110 100 32 115 101 118 101 110

By looking in the ASCII table, you can see a one-to-one correspondence
between each character and the ASCII code used. Note the use of 32 for a
space \-- 32 is the ASCII code for a space. We could expand these
decimal numbers out to binary numbers (so 32 = 00100000) if we wanted to
be technically correct \-- that is how the computer really deals with
things.

**Standard ASCII Character Set**\
The first 32 values (0 through 31) are codes for things like carriage
return and line feed. The space character is the 33rd value, followed by
punctuation, digits, uppercase characters and lowercase characters.

+-----------------+-----------------+-----------------+-----------------+
| > 0 NUL         | > 32            | > 64 @          | > 96 \`         |
| >               | >               | >               | >               |
| > 1 SOH         | > 33 !          | > 65 A          | > 97 a          |
| >               | >               | >               | >               |
| > 2 STX         | > 34 \"         | > 66 B          | > 98 b          |
| >               | >               | >               | >               |
| > 3 ETX         | > 35 \#         | > 67 C          | > 99 c          |
| >               | >               | >               | >               |
| > 4 EOT         | > 36 \$         | > 68 D          | > 100 d         |
| >               | >               | >               | >               |
| > 5 ENQ         | > 37 %          | > 69 E          | > 101 e         |
| >               | >               | >               | >               |
| > 6 ACK         | > 38 &          | > 70 F          | > 102 f         |
| >               | >               | >               | >               |
| > 7 BEL         | > 39 \'         | > 71 G          | > 103 g         |
| >               | >               | >               | >               |
| > 8 BS          | > 40 (          | > 72 H          | > 104 h         |
| >               | >               | >               | >               |
| > 9 TAB         | > 41 )          | > 73 I          | > 105 i         |
| >               | >               | >               | >               |
| > 10 LF         | > 42 \*         | > 74 J          | > 106 j         |
| >               | >               | >               | >               |
| > 11 VT         | > 43 +          | > 75 K          | > 107 k         |
| >               | >               | >               | >               |
| > 12 FF         | > 44 ,          | > 76 L          | > 108 l         |
| >               | >               | >               | >               |
| > 13 CR         | > 45 -          | > 77 M          | > 109 m         |
| >               | >               | >               | >               |
| > 14 SO         | > 46 .          | > 78 N          | > 110 n         |
| >               | >               | >               | >               |
| > 15 SI         | > 47 /          | > 79 O          | > 111 o         |
| >               | >               | >               | >               |
| > 16 DLE        | > 48 0          | > 80 P          | > 112 p         |
| >               | >               | >               | >               |
| > 17 DC1        | > 49 1          | > 81 Q          | > 113 q         |
| >               | >               | >               | >               |
| > 18 DC2        | > 50 2          | > 82 R          | > 114 r         |
| >               | >               | >               | >               |
| > 19 DC3        | > 51 3          | > 83 S          | > 115 s         |
| >               | >               | >               | >               |
| > 20 DC4        | > 52 4          | > 84 T          | > 116 t         |
| >               | >               | >               | >               |
| > 21 NAK        | > 53 5          | > 85 U          | > 117 u         |
| >               | >               | >               | >               |
| > 22 SYN        | > 54 6          | > 86 V          | > 118 v         |
| >               | >               | >               | >               |
| > 23 ETB        | > 55 7          | > 87 W          | > 119 w         |
| >               | >               | >               | >               |
| > 24 CAN        | > 56 8          | > 88 X          | > 120 x         |
| >               | >               | >               | >               |
| > 25 EM         | > 57 9          | > 89 Y          | > 121 y         |
| >               | >               | >               | >               |
| > 26 SUB        | > 58 :          | > 90 Z          | > 122 z         |
| >               | >               | >               | >               |
| > 27 ESC        | > 59 ;          | > 91 \[         | > 123 {         |
| >               | >               | >               | >               |
| > 28 FS         | > 60 \<         | > 92 \\         | > 124 \|        |
| >               | >               | >               | >               |
| > 29 GS         | > 61 =          | > 93 \]         | > 125 }         |
| >               | >               | >               | >               |
| > 30 RS         | > 62 \>         | > 94 \^         | > 126 \~        |
| >               | >               | >               | >               |
| > 31 US         | > 63 ?          | > 95 \_         | > 127 DEL       |
+-----------------+-----------------+-----------------+-----------------+

# Lots of Bytes

When you start talking about lots of bytes, you get into **prefixes**
like kilo, mega and giga, as in kilobyte, megabyte and gigabyte (also
shortened to K, M and G, as in Kbytes, Mbytes and Gbytes or KB, MB and
GB).

The following table shows the **binary** multipliers:

  ---------- ----------- ------------------------------------------------------
  **Name**   **Abbr.**   **Size**

  Kilo       K           2\^10 = 1,024

  Mega       M           2\^20 = 1,048,576

  Giga       G           2\^30 = 1,073,741,824

  Tera       T           2\^40 = 1,099,511,627,776

  Peta       P           2\^50 = 1,125,899,906,842,624

  Exa        E           2\^60 = 1,152,921,504,606,846,976

  Zetta      Z           2\^70 = 1,180,591,620,717,411,303,424

  Yotta      Y           2\^80 = 1,208,925,819,614,629,174,706,176
  ---------- ----------- ------------------------------------------------------

You can see in this chart that kilo is about a thousand, mega is about a
million, giga is about a billion, and so on. So when someone says,
\"This computer has a 2 gig hard drive,\" what he or she means is that
the hard drive stores 2 gigabytes, or approximately 2 billion bytes, or
exactly 2,147,483,648 bytes. How could you possibly need 2 gigabytes of
space? When you consider that one
[[CD]{.underline}](http://computer.howstuffworks.com/cd.htm) holds 650
megabytes, you can see that just three CDs worth of data will fill the
whole thing! Terabyte databases are fairly common these days, and there
are probably a few petabyte databases floating around the
[[Pentagon]{.underline}](http://computer.howstuffworks.com/framed.htm?parent=bytes.htm&url=http://www.defenselink.mil/pubs/pentagon/)
by now

Some common examples:

A double-spaced typewritten page, with 10 characters per inch, has about
1750 bytes.

A single-space typewritten page of the same information would be double
or about 3,500 bytes or 3.5 Kilobytes, or KB.

A text only page, in the New York Times that is, with no pictures, with
6 columns of text, 155 lines per column and 35 characters per line ends
up being about 32,550 characters or 32.5 KB.

The average hardcover novel with about 300 pages has 1 million
characters, which would take 1 MB to store on a computer.

For some real examples,

*Catcher in the Rye* is 400 KB.

*Gone with the Wind* is about 2.5MB.

As of 2000, the United States Library of Congress has about 20 million
books for a total of 20 trillion characters or 20 TB.

**Digital Pictures**

All forms of digital media are really just bytes of information. Digital
cameras capture images dot by dot (also known as pixels). The total
number of pixels determines the image resolution. The more pixels a
camera has, the more detail it can capture and the larger pictures can
be without becoming blurry or \"grainy.\"

Some typical resolutions include:

-   **256x256** - Found on very cheap cameras, this resolution is so low
    that the picture quality is almost always unacceptable. This is
    65,000 total pixels.

-   **640x480** - This is the low end on most \"real\" cameras. This
    resolution is ideal for e-mailing pictures or posting pictures on a
    Web site.

-   **1216x912** - This is a \"megapixel\" image size \-- 1,109,000
    total pixels \-- good for printing pictures.

-   **1600x1200** - With almost 2 million total pixels, this is \"high
    resolution.\" You can print a 4x5 inch print taken at this
    resolution with the same quality that you would get from a photo
    lab.

-   **2240x1680** - Found on 4 megapixel cameras \-- the current
    standard \-- this allows even larger printed photos, with good
    quality for prints up to 16x20 inches.

-   **4064x2704** - A top-of-the-line digital camera with 11.1
    megapixels takes pictures at this resolution. At this setting, you
    can create 13.5x9 inch prints with no loss of picture quality.

No matter what type of storage they use, all digital cameras need lots
of room for pictures. They usually store images in one of two formats
\-- TIFF, which is uncompressed, and JPEG, which is compressed. Most
cameras use the JPEG file format for storing pictures, and they
sometimes offer quality settings (such as medium or high). The following
chart will give you an idea of the file sizes you might expect with
different picture sizes.

  ------------- -------------------- ---------------- --------------------
  **Image       **TIFF**\            **JPEG**\        **JPEG**\
  Size**        (uncompressed)       (high quality)   (medium quality)

  640x480       1.0 MB               300 KB           90 KB

  800x600       1.5 MB               500 KB           130 KB

  1024x768      2.5 MB               800 KB           200 KB

  1600x1200     6.0 MB               1.7 MB           420 KB
  ------------- -------------------- ---------------- --------------------

**Music**

Like pictures, music can be stored on a computer or on storage media in
a digital format. CDs and DVDs hold music movies in a number of formats.
MP3 files are now a very popular format for music which also uses
compression. A typical format is to sample the music 44,000 per second,
with 128 bits per sample.

A minute of music is about 1MB, so a song like Little Wing by Government
Mule, which is 4:00 minutes long is 3.67 MB. So, to store 500 songs, you
need about 2 GB, and to store 1000 songs, about 4 GB.

**Storage Devices**

There are many types of devices that can store digital data. Computer
disk drives, CDs, DVDs, Flash drives, iPods etc. all can store some or
all of the files types we have discussed - text files, pictures,
programs, music, etc.

Some common examples --

Computer Disk Drive ranging from 20 GB to 400 GB or more, 80 GB is
typical

CD ROM disk 650 -- 700 MB

DVD ROM disk, single side 4GB

DVD ROM disk, double sided 8GB

Flash drive 128 MB, 256 MB, 512, MB, 1 GB

MP3 Player 1 GB

iPOD nano 2GB, 4GB and 8GB