Файл: Microcontroller Programming. Thi Micro Chip PIC (Julio Sanchez, 2007).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 14.06.2025
Просмотров: 8546
Скачиваний: 0
Number Systems |
21 |
By the 9th century A.D. the Arabs were using a ten-symbol positional system of numbers which included the special symbol for 0. The Latin title of the first book on the subject of "Indian numbers" is Liber Algorismi de Numero Indorum. The author is the Arab mathematician al-Khowarizmi.
In spite of the evident advantages of this number system its adoption in Europe took place only after considerable debate and controversy. Many scholars of the time still considered Roman numerals to be easier to learn and more convenient for operations on the abacus. The supporters of the Roman numeral system, called abacists, engaged in intellectual combat with the algorists, who were in favor of the Hindu-Arabic numerals as described by al-Khowarizmi. For several centuries abacists and algorists debated about the advantages of their systems, with the Catholic church often siding with the abacists. This controversy explains why the Hindu-Arabic numerals were not accepted into general use in Europe until the beginning of the 16th century.
It is sometimes said that the reason for there being ten symbols in the Hindu-Arabic numerals is related to the fact that we have ten fingers. However, if we make a one-to-one correlation between the Hindu-Arabic numerals and our fingers, we find that the last finger must be represented by a combination of two symbols, 10. Also, one Hindu-Arabic symbol, 0, cannot be matched to an individual finger. In fact, the decimal system of numbers, as used in a positional notation that includes a zero digit, is a refined and abstract scheme which should be considered one of the greatest achievements of human intelligence. We will never know for certain if the Hindu-Arabic numerals are related to the fact that we have ten fingers, but its profoundness and usefulness clearly transcends this biological fact.
The most significant feature of the Hindu-Arabic numerals is the presence of a special symbol, 0, which by itself represents no quantity. Nevertheless, the special symbol 0 is combined with the other ones. In this manner the nine other symbols are reused to represent larger quantities. Another characteristic of decimal numbers is that the value of each digit depends on its position in a digit string. This positional characteristic, in conjunction with the use of the special symbol 0 as a placeholder, allows the following representations:
1 = one
10 = ten
100 = hundred
1000 = thousand
The result is a counting scheme where the value of each symbol is determined by its column position. This positional feature requires the use of the special symbol, 0, which does not correspond to any unit-amount, but is used as a place-holder in multicolumn representations. We must marvel at the intelligence, capability for abstraction, and even the sense of humor of the mind that conceived a counting system that has a symbol that represents nothing. We must also wonder about the evolution of mathematics, science, and technology had this system not been invented. One intriguing question is whether a positional counting system that includes the zero symbol is a natural and predictable step in the evolution of our mathematical
22 |
Chapter 2 |
thought, or whether its invention was a stroke of genius that could have been missed for the next two thousand years.
2.1.1 Number Systems for Digital-Electronics
The computers built in the United States during the early 1940s operated on decimal numbers. However, in 1946, von Neumann, Burks, and Goldstine published a trend-setting paper titled Preliminary Discussion of the Logical Design of an Electronic Computing Instrument, in which they state:
"In a discussion of the arithmetic organs of a computing machine one is naturally led to a consideration of the number system to be adopted. In spite of the long-standing tradition of building digital machines in the decimal system, we must feel strongly in favor of the binary system for our device."
In their paper, von Neumann, Burks, and Goldstine also consider the possibility of a computing device that uses binary-coded decimal numbers. However, the idea is discarded in favor of a pure binary encoding. The argument is that binary numbers are more compact than binary-coded decimals. Later in this book you will see that binary-coded decimal numbers (called BCD) are used today in some types of computer calculations.
In 1941, Konrad Zuse, a German who had done pioneering work in computing machines, released the first programmable computer designed to solve complex engineering equations. The machine, called the Z3, was controlled by perforated strips of discarded movie film and used the binary number system.
The use of the binary number system in digital calculators and computers was made possible by previous research on number systems and on numerical representations, starting with an article by G.W. Leibnitz published in Paris in 1703. Researchers concluded that it is possible to count and perform arithmetic operations using any set of symbols as long as the set contains at least two symbols, one of which must be zero.
In digital electronics the binary symbol 1 is equated with the electronic state ON, and the binary symbol 0 with the state OFF. The two symbols of the binary system can also represent conducting and nonconducting states, positive or negative, or any other bi-valued condition. It was the binary system that presented the Hindu-Arabic decimal number system with the first challenge in 800 years. In digi- tal-electronics two steady states are easier to implement and more reliable than a ten-digit encoding.
2.1.2 Positional Characteristics
All modern number systems, including decimal, hexadecimal, and binary, are positional and include the digit zero. It is the positional feature that is used to determine the total value of a multi-digit representation. For example, the digits in the decimal number 4359 have the following positional weights:
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 |