Binary Numbers

September 1996, -jr


Here's a very simple description of binary arithmetic. For more theory, see the Savitch book at page 545 - 548.


Representation

Binary numbers and arithmetic let you represent any amount you want using just two digits: 0 and 1. Here are some examples:

Decimal 1 is binary 0001
Decimal 3 is binary 0011
Decimal 6 is binary 0110
Decimal 9 is binary 1001

Each digit "1" in a binary number represents a power of two, and each "0" represents zero:

0001 is 2 to the zero power, or 1
0010 is 2 to the 1st power, or 2
0100 is 2 to the 2nd power, or 4
1000 is 2 to the 3rd power, or 8.

When you see a number like "0101" you can figure out what it means by adding the powers of 2:

0101 = 0 + 4 + 0 + 1 = 5
1010 = 8 + 0 + 2 + 0 = 10
0111 = 0 + 4 + 2 + 1 = 7

Addition

Adding two binary numbers together is like adding decimal numbers, except 1 + 1 = 10 (in binary, that is), so you have to carry the one to the next column:

  0001
+ 0100
  ----
  0101 (no carries to get this)
  0001
+ 0001 
  ----
  0010 (1 plus 1 is 10, carry the 1 to the next column)
  0011
+ 0011 
  ----
  0110 (1 + 1 = 10, so carry; then 1 + 1 + 1 = 11, so carry again)
  0011
+ 0101 
  ----
  1000 (carry in every column here)

Subtraction is harder. Don't worry about it.

Larger Numbers

Here are the numbers from 0 to 15, in binary:

0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15

To represent bigger whole numbers (integers), you need more bits -- more places in the binary number:

10000101 = 128 + 0 + 0 + 0 + 0 + 4 + 0 + 1 = 133.

That was 8 bits:

Some other terms you'll hear are:

Typical sizes for personal computer RAM (random access memory) are 4 to 16 megabytes, while hard disks now start around 150 megabytes. Since each byte can represent one character of the alphabet, that means a hard disk might hold something like 150 million characters, or 25 million words of "raw" text. Documents formatted in a word processor take up a lot more space, though, and the operating system and software usually fill at least 100 megabytes.

To represent real numbers, fractions, or very large numbers, binary systems use "floating point arithmetic." That's another topic.

Why Use 'Em?

For computers, binary numbers are great stuff because:


Practice Problems

For practice, figure out what these numbers stand for, then check your answer in the list above: 1011, 0110, 0010. Now look up these numbers in the list above and try adding them: 5 + 7, 3 + 8, 6 + 11. Check your answers against the list.


RETURN to CSCI 1200 Home Page

- John Rieman