Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microcontroller Programming. Thi Micro Chip PIC (Julio Sanchez, 2007).pdf
Скачиваний:
475
Добавлен:
12.08.2013
Размер:
4.99 Mб
Скачать

Number Systems

 

 

23

4

3

5

9

 

| | | |_________________

units

| | |___________________

ten units

| |_____________________

hundred units

|_______________________

thousand units

The total value is obtained by adding the column weights of each unit:

4000 --- 4 thousand units

300 --- 3 hundred units

+50 --- 5 ten units

9 --- 9 unit

----

4359

2.1.3 Radix or Base of a Number System

In any positional number system the weight of each column is determined by the total number of symbols in the set, including zero. This is called the base or radix of the system. The base of the decimal system is 10 and the base of the binary system is 2. The positional value or weight (P) of a digit in a multi-digit number is determined by the formula:

P = d × Bc

where d is the digit, B is the base or radix, and c is the zero-based column number, starting from right to left. Note that the increase in column weight from right to left is purely conventional. You could construct a number system in which the column weights increase in the opposite direction. In fact, in the original Hindu notation the most significant digit was placed at the right.

In radix-positional terms a decimal number can be expressed as a sum of digits by the formula:

di × 10i

i= − mn

where i is the system's range and n is its limit.

2.2 Types of Numbers

By the adoption of special representations for different types of numbers the usefulness of a positional number system can be extended beyond the simple counting function.

24

Chapter 2

2.2.1 Whole Numbers

The digits of a number system, called the positive integers or natural numbers, are an ordered set of symbols. The notion of an ordered set means that the numerical symbols are assigned a predetermined sequence. A positional system of numbers also requires the special digit zero which, by itself, represents the absence of oneness, or nothing, and thus is not included in the set of natural numbers. However, 0 assumes a cardinal function when it is combined with other digits, for instance, 10 or 30. The whole numbers are the set of natural numbers, including the number zero.

2.2.2 Signed Numbers

A number system can also encode direction. We generally use the + and - signs to represent opposite numerical directions. The typical illustration for a set of signed numbers is as follows:

-9 -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 +9

negative numbers <-

zero

-> positive numbers

The number zero, which separates the positive and the negative numbers, has no sign of its own, although in some binary encodings we can end up with a negative and a positive zero.

2.2.3 Rational, Irrational, and Imaginary Numbers

A number system also represents parts of a whole. For example, when a carpenter cuts one board into two boards of equal length we can represent the result with the fraction 1/2; the fraction 1/2 represents one of the two parts which make up the object. Rational numbers are those expressed as a ratio of two integers, for example, 1/2, 2/3, 5/248. Note that this use of the word rational is related to the mathematical concept of a ratio, and not to reason.

The denominator of a rational number expresses the number of potential parts. In this sense 2/5 indicates two of five possible parts. There is no reason why the number 1 cannot be used to indicate the number of potential parts, for example 2/1, 128/1. In this case the ratio x/1 indicates x elements of an undivided part. Therefore, it follows that x/1 = x. The implication is that the set of rational numbers includes the integers, since an integer can be expressed as a ratio by using a unit denominator.

But not all non-integer numbers can be written as an exact ratio of two integers. The discovery of the first irrational number is usually associated with the investigation of a right triangle by the Greek mathematician Pythagoras (approximately 600 BC). The Pythagorean Theorem states that in any right triangle the square of the longest side (hypotenuse) is equal to the sum of the squares of the other two sides.

C

a = 1

b = 1

Number Systems

25

For this triangle, the Pythagorean theorem states that

a2 + b2

= c2

2 = c2

2 = c × c c = 2

Therefore, the length of the hypotenuse in a right triangle with unit sides is a number that, when multiplied by itself, gives 2. This number (approximately 1.414213562) cannot be expressed as the exact ratio of two integers. Other irrational numbers are the square roots of 3 and 5, as well as the mathematical constants π and e.

The set of numbers that includes the natural numbers, the whole numbers, and the rational and irrational numbers is called the real numbers. Most common mathematical problems are solved using real numbers. However, during the investigation of squares and roots we notice that there can be no real number whose square is negative. Mathematicians of the 18th century extended the number system to include operations with roots of negative numbers. They did this by defining an imaginary unit as follows:

i = 1

The imaginary unit makes possible a new set of numbers, called complex numbers, that consist of a real part and an imaginary part. One of the uses of complex numbers is in finding the solution of a quadratic equation. Complex numbers are also useful in vector analysis, graphics, and in solving many engineering, scientific, and mathematical problems.

2.3 Radix Representations

The radix of a number system is the number of symbols in the set, including zero. Thus, the radix of the decimal system is 10, and the radix of the binary system is 2. Digital electronics is based on circuits that can be in one of two stable states. Therefore, a number system based on two symbols is better suited for work in digital electronics, since each state can be represented by a digit.

2.3.1 Decimal versus Binary Numbers

The binary system of numbers uses two symbols, 1 and 0. It is the simplest possible set of symbols with which we can count and perform arithmetic. Most of the difficulties in learning and using the binary system arise from this simplicity. Figure 2.1 shows sixteen groups of four electronic cells each in all possible combinations of two states.

26 Chapter 2

0

0

0

0

0

0

0

1

0

0

1

0

0

0

1

1

0

1

0

0

0

1

0

1

0

1

1

0

0

1

1

1

1

0

0

0

1

0

0

1

1

0

1

0

1

0

1

1

1

1

0

0

1

1

0

1

1

1

1

0

1

1

1

1

Figure 2-1 Electronic Cells and Binary Numbers

It is interesting to note that binary numbers match the physical state of each electronic cell. If we think of each cell as a miniature light bulb, then the binary number 1 can be used to represent the state of a charged cell (light ON) and the binary number 0 to represent the state of an uncharged cell (light OFF).

2.3.2 Hexadecimal and Octal

Binary numbers are convenient in digital electronics; however, one of their drawbacks is the number of symbols required to encode a large value. For example, the number 9134 is represented in four decimal digits. However, the binary equivalent 10001110101110 requires fourteen digits. In addition, large binary numbers are difficult to remember.

One possible way of compensating for these limitations of binary numbers is to use individual symbols to represent groups of binary digits. For example, a group of three binary numbers allows eight possible combinations. In this case, we can use the decimal digits 0 to 7 to represent each possible combination of three binary digits. This grouping of three binary digits gives rise to the following table:

binary

octal

0

0

0

0

0

0

1

1

0

1

0

2

0

1

1

3

1

0

0

4

1

0

1

5

1

1

0

6

1

1

1

7