Before you start

  • You can do arithmetic with whole numbers and fractions.
  • You have met number bases, though it is not required.

What you will be able to do after this lesson:

  1. Name the number systems in order and say what each one adds.
  2. Explain what problem each extension was invented to solve.
  3. Decide which system a given quantity needs.
  4. Explain why the reals are needed and what irrational means.

Study route: read the lesson, then attempt every problem before opening the answers.


Before computers can manipulate information, we need something to represent the information with.

The most fundamental mathematical objects we use for this are numbers.

But interestingly, mathematics doesn’t have just one “type” of number.

We have different number systems.


1.1 Natural Numbers

These are the numbers we use for counting.

Depending on convention, you’ll see either:

or

We’ll use the second convention:

Think:

“How many?”

For example:

  • 0 computers
  • 1 computer
  • 2 computers
  • 50 computers
  • 1,000 computers

You can’t have 2.7 computers in ordinary counting.

So natural numbers are useful for discrete quantities.

And notice something important already.

A computer is fundamentally a discrete system.

That connection will become VERY important in Week 2.


1.2 Integers

Now suppose you want to represent things like:

  • temperatures below zero
  • money you owe
  • movement backward
  • a position to the left of zero

Natural numbers aren’t enough.

So we introduce negative numbers.

The integers are:

For example:

← negative                 positive →
---|---|---|---|---|---|--->
  -3  -2  -1   0   1   2   3

So:

are all integers.

But:

isn’t an integer.

Neither is:


1.3 Rational Numbers

Now we encounter fractions.

A rational number is any number that can be expressed as:

where (p) and (q) are integers and:

Examples:

So integers are actually rational numbers too.

For example:

This means:

Read that as:

“The integers are a subset of the rational numbers.”


Something interesting happens with decimals

Consider:

Easy.

Now:

The decimal continues forever.

But it is still rational because it can be written as:

So a rational number can have either:

  • a terminating decimal
  • or a repeating decimal

For example:

and


1.4 Real Numbers

Now we encounter numbers that cannot be represented as a fraction of two integers.

For example:

There is no pair of integers (p,q) such that:

Another famous example is:

These are called irrational numbers.

So the real numbers contain both:

Rational numbers

and irrational numbers:

Therefore:

And our hierarchy becomes:

Natural numbers
      ↓
   Integers
      ↓
Rational numbers
      ↓
  Real numbers

More formally:

That’s an important relationship to remember.


Why do we care about all these categories?

Because later, when we’re dealing with computers, we’ll repeatedly ask:

What kind of value are we representing?

For example:

A CPU register might contain:

00001101

What does that mean?

It could represent:

It could represent:

It could be part of a memory address.

It could represent a character.

It could be part of a floating-point number.

The physical bits themselves don’t inherently “mean” anything.

The representation system gives them meaning.

And that is going to become one of the biggest ideas in our entire course.


Practice — problems

Attempt all of these before opening the answers.

  1. Which system is the smallest that contains each of these? , , , , , , .
  2. Closure. A set is closed under an operation if the result is always still in the set. For each of , say whether it is closed under addition, subtraction, multiplication and division. The gaps in that table are exactly why each new system was invented.
  3. Prove is irrational. Assume in lowest terms and derive a contradiction.
  4. Why does a computer’s int type not model ? Name two ways it differs.
Answers — open only after an attempt
  1. ; ; (irrational); by most modern conventions, otherwise ; ; (it is ); .
  2. : closed under and only. : adds closure under . : adds closure under (except by zero). : adds closure under limits, which is what makes and exist. Each system is the previous one plus whatever was needed to close an operation.
  3. If in lowest terms, then , so is even, so is even. Write : then , so and is even too. But then and share a factor of 2, contradicting “lowest terms”.
  4. It is finite (a 32-bit int stops at about 2.1 billion and wraps or overflows), and it is not closed under division (integer division truncates). See data representation.

Before moving on

You are done with this lesson when you can, closed-book:

  • Name the number systems in order and what each adds.
  • State which operations each system is closed under.
  • Prove is irrational.
  • Explain why a machine integer is not .

Recap: Each number system exists because the previous one could not answer a question. Naturals count but cannot express debt, so integers add negatives. Integers cannot divide evenly, so rationals add fractions. Rationals leave gaps on the line — is not a ratio of whole numbers — so reals fill them. Each extension is the smallest one that closes an operation the previous system could not.

Next: Sets — the language used to state precisely what a number system is.

↑ Back to Mathematics