Natural numbers

Numbers that are used by people every day for counting and ordering: This is called decimal or base-10. With a single digit, the largest value that can be represented is 9. To create large numbers we add a new digit to to the left to give the numbers 10…99 and so on.

  • Each extra digit is worth ten times the previous digit.
  • This idea is important because it applies to other number systems as well.
  • We can use this number system to represent an infinite range on numbers.
    • The natural numbers range from
  • The inclusion of zero is important in programming because arrays and looping structures usually start from 0.

The set of natural numbers has the symbol so we can write:

Integer numbers

An integer is a whole number whose value can be either negative or positive. 0 is classed as an integer. A whole number does not contain a fractional part (ie. No fractions or decimal points).

  • Negative values are pre-seeded by a minus sign (“”).

The word Bit is a contraction of Binary digit

Integers are a standard data type used in most programming languages. They are used for variables and constants. For example in visual basic, an integer is stored in 4 bytes and can store values from -2147483648 to 2147483647. The positive numbers are smaller because the range includes 0. Values out of this range are stored in a different data type called Long in visual basic. The symbol for integers is (Zahlen). So we can write:

Rational Numbers

A rational number is one that can be expressed as a fraction. Fractions are made up from 2 integers, with the value being the ration between the 2 integers. Rational numbers can be represented by a fraction or the decimal equivalent.:

The top integer is called the numerator and the bottom integer is called the denominator. The number can be any integer - any whole number. The values of fractions can be positive or negative, and greater or less than 1 (or 0).

As these examples show, all integers can also be expressed as rational numbers. The denominator can have any value except 0. Dividing by 0 gives an indeterminate value and a divide by 0 gives a zero-error in most languages. The symbol for the set of rational numbers is .

Irrational Numbers

An irrational number is any number that cannot be represented as a ratio of integers because the decimal equivalent goes on forever without repeating. A classic example of an irrational number is (pi). The commonly used approximation for is . In decimal form the number has an infinite number of decimal places so it has to be truncated to a set of decimal places.

Eg: or

More decimal places gives greater precision.

to 3 decimal places.

NB: so be careful when approximating.


is NOT an irratioinal number because:

  1. It is the ratio between 2 integers
  2. The digits of the decimal do repeat.

For programmers it is important to consider the precision that is needed when using irrational numbers. The programmer needs to decide what precision to use. However, this option is not always available.

For example, in Python:

>>> import math
>>> math.pi
>>> # You have no choice as to how many decimal places pi is given to.