Instructional Module G17c

Number Systems in Computers

Contents

About this Document

Audience and Objectives


Storing Stuff in Computers

Most people know that everything in computers is stored using numbers, and that the basic numbers the computer stores are zero and one.

But why do computers stick to 0 and 1, and how can they use only those two numbers to do so much? That's the topic of this module.

Why Base Two?

John V. Atanasoff

The number system in computers is base two, or binary. This is because of mathematician John V. Atanasoff's decision in 1938 to try building an all-electronic computing device using the simplest numbering system available. Base two has only two digits: 0 and 1.

In everyday life, we use the base 10 decimal number system. But Atanasoff tried using that to build a computer, and it was much too complicated.

The numbers 0 and 1 can easily be represented in many devices, and from Atanasoff's successful experiment using vacuum tubes has come our entire world of digital electronics.

Bits

The utility of binary numbers is that they can be represented in very simple ways.

  • First: a pair of vacuum tubes
  • Then: Holes in punched cards or paper tape (the hole is either there or not there)
  • Later: Magnetized spots on tape or disks (magnetism can be north-south or south-north)
  • High vs. low voltage in wires
  • On-Off pulses of light
  • Pits on optical disks (CDs and DVDs)
  • ...or any other device you can think of that's in either one of two states.

No matter how it's done physically, these two- state (on/off) devices can represent a single binary digit: zero or one.

A binary digit is called a bit.

You can think of a bit like a little light: either on or off.

bit off bit on
off
on

Grouping Bits

One bit by itself has only limited value. But when several of them are grouped together, they're pretty powerful.

Since the system is based on two states, it makes sense to join bits together in multiples of two: 4, 8, 16, 32, 64, etc. Here's what those multiples are called:

bits name
4
nybble
8
byte or octet
16
word
32
32-bit word
64
64-bit word

Of these, the most important and familiar is byte.

A byte is 8 bits
byte
A byte offers 256 different combinations of on/off bits

Bytes are especially useful because:

One byte holds one character

  • A character is a letter or other symbol used in writing.
  • A single byte holds a single character of a European language. To represent characters in other languages, two or more bytes may be used.

Numbering Systems

When you use computers a lot, you're likely to run into three ways of representing numbers:

  • binary - of course!
  • decimal - base 10, the system we use in everyday life
  • hexadecimal - base 16, used for convenience in many computer applications

Representing Binary Numbers


Binary numbers are simple, but they are clumsy for people to use because, to represent numbers greater than 1, more digits have to be used. Here are a few examples, just to give you the picture:

  • 2 in our normal decimal system is 10 binary
  • 5 decimal is 101 binary
  • 10 decimal is 1010 binary
  • 100 decimal is 1100100 binary
  • 16,777,215 decimal is 111111111111111111111111

You can see that it is very easy to take up a lot of space and get confused!

Computers and humans do best when binary numbers are divided into chunks. The most logical chunks for binary numbers is in powers of two, such as 2, 4, 8, 16, 32... We could make the larger numbers above a little easier to understand by "chunking" into groups of 4, like this:

  • 100 decimal is 110,0100 binary
  • 16,777,215 decimal is 1111,1111,1111,1111,1111,1111 binary

Why Hexadecimal?

That's better, but even more bulky. How to compress the notation, and still maintain the groupings of binary digits that are fundamental to the "nybbles" (4 bits) and "bytes" (8 bits) of computer memory and disk storage? And why do many computer applications use hexadecimal numbering?

The answer lies in using a number base that is a power of 2 (2, 4, 8, 16, 32). In the 1960s and 1970s, octal (base 8) notation was commonly used. Base 16 is more convenient though, because of the universal division of computer memory into bytes of 8 bits each: two base-sixteen digits exactly represent one byte of memory.

There's only one problem: we don't have 16 digits available! After 9, we run out.

The solution is to take the letters of the alphabet and press them into service above the number 9. The next section shows how this works...

Binary-Decimal-Hex


Here is a chart of the first 16 numbers in three number bases:

 

Base 2
Binary

Base 10
decimal
Base 16
hexadecimal
one
1
1
1
two
10
2
2
three
11
3
3
four
100
4
4
five
101
5
5
six
110
6
6
seven
111
7
7
eight
1000
8
8
nine
1001
9
9
ten
1010
10
A
eleven
1011
11
B
twelve
1100
12
C
thirteen
1101
13
D
fourteen
1110
14
E
fifteen
1111
15
F
sixteen
1,0000
16
10

Hexadecimal notation is clearly the most compact of the three ways to represent numbers. Here are those larger numbers:

  • 110,0100 binary is100 decimal and 64 hexadecimal
  • 1111,1111,1111,1111,1111,1111 binary is 16,777,215 decimal and FFFFFF hexadecimal.

To explore hexadecimal numbering, see Hypersolutions Thinking Hexadecimally, at http://www.hypersolutions.org/pages/hex.html. This includes a built-in converter from decimal to hex and back again.

Calculator in Scientific mode, showing number base selector.If you want a quick way to convert numbers to different bases, the Windows calc program can do it. To start the calculator:

  • Start > (All) Programs > Accessories > Calculator
  • Start > Run and type calc

The program usually looks like a simple calculator, but under the View menu you can change it to look like a scientific calculator. In this view, you can convert numbers to and from Hexadecimal, Decimal, Octal, and Binary, by clicking on a radio-button below the display window (shown in the accompanying figure).

 

 

About this document...

Audience:

This is for people who want to understand the basics of number storage and representation in computers. No previous knowledge is required.

Objectives:

When you successfully complete this lesson, you will be able to...

  1. Explain why binary numbers are used in computers
  2. Explain the concept of bits
  3. Discuss why and how bits are grouped and give names to at least two common groupings of bits
  4. Relate the binary numbering system to decimal and hexadecimal systems

Module g17c:

This document is part of a modular instruction series in Computer Information Systems. For more information, see the overview or the list of modules in this series, W: World Wide Web.This document has been used in the following classes: CIS 100

Author:

Laurence J. Krieg

Institution:

Computer Information Systems Department, Washtenaw Community College
History: Original: 20 February 2006; parts derived from module W22e.
Last modification:  Tuesday, 21-Feb-2006 08:42:51 EST
Copyright: Copyright © 2006, Laurence J. Krieg, Washtenaw Community College.
Instructors: You may point to this file in your Web-based materials.
Students: you may make a copy for your personal use.
All other uses: contact the author, Laurence J. Krieg for permission. Email krieg@ieee.org