انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

APPENDIX B: Positional Numbering Systems

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 4
أستاذ المادة علي كاظم ادريس السعدي       16/01/2017 16:34:05
A
positional number system uses a set of symbols. The value that
each symbol represents, however, depends on its face value and its
place value, the value associated with the position it occupies in the num-
ber, In other words, we have
Symbol value = Face value × Place value
Number value = Sum of Symbol values
In this appendix, we discuss only integers, numbers with no fractional
part; the discussion of reals, numbers with a fractional part is similar.

B.1 DIFFERENT SYSTEMS
We first show how integers can be represented in four different systems:
base 10, base 2, base 16, and base 256.
Base 10: Decimal
The first positional system we discuss is called the decimal system. The
term decimal is derived from the Latin root decem (meaning ten). The dec-
imal system uses 10 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) with the same
face values as the symbols. The place values in the decimal number system
are powers of 10. Figure B.1 shows the place values and the symbol values
in the integer 4,782.

Base 2: Binary
The second positional system we discuss is called the binary system. The term binary is
derived from the Latin root bi (meaning two by two). The binary system uses 2 symbols
(0 and 1) with the same face values as the symbols. The place values in the binary num-
ber system are powers of 2. Figure B.2 shows the place values and the symbol values in
the binary (1101) 2 . Note that we use subscript 2 to show that the number is in binary.

Base 16: Hexadecimal
The third positional system we discuss is called the hexadecimal system. The term
hexadecimal is derived from the Greek root hex (meaning 6) and the Latin root decem
(meaning ten). The hexadecimal system uses 16 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,
B, C, D, E, and F). The face value of the ten symbols are the same as the symbols, but
the face values of the symbols A to F are 10 to 15 respectively. The place values in the
hexadecimal number system are powers of 16. Figure B.3 shows the place values and
the symbol values in the hexadecimal (A20E) 16 . Note that we use subscript 16 to show
that the number is in hexadecimal.

Base 256: Dotted-Decimal Notation
The fourth positional system we discuss is the base 256, which is called dotted-decimal
notation. This system is used to represent IPv4 addressing. The place values in this sys-
tem are powers of 256. However, since using 256 symbols is almost impossible, the
symbols in this system are decimal numbers between 0 and 255, with the same face val-
ues as the symbols. To separate these numbers from each other, the system uses a dot as
discussed in Chapter 5. Figure B.4 shows the place values and the symbol values of the
address (14.18.111.252). Note that we never use more than four symbols in an IPv4
address.

Conversion from Any Base to Decimal
Figures B.2 to B.4 actually show how we can manually convert a number in any base to
decimal. However, it is easier to use the algorithm in Figure B.5. The algorithm uses the
fact that the next place value is the previous value multiplied by the base (2, 16, or 256).
The algorithm is a general one that can be used to convert a string of symbols in a given
base to a decimal number. The only section in the algorithm that is different for each
base is how to extract the next symbol in the string and find its face value. In the case of
base 2, it is simple; the face value can be found by changing the symbol to a numeric
value. In the case of base 16, we need to consider the case that the face value of symbol A
is 10, the face value of symbol B is 11, and so on. In the case of base 256, we need to
extract each string delimited by dots and change the string to its numerical value. We
leave the details of these subalgorithms as an exercise because they are normally
language-dependent.

Conversion from Decimal to Any Base
Conversion from a decimal value to any base can be done if we continuously divide the
decimal number by the base to find the remainder and the quotient. The remainder is
the face value of the next symbol; the quotient is the decimal value to be used in the
next iteration. As in the case of inverse conversion, we need to have a separate algo-
rithm to change the face value of a symbol, in the corresponding base, to the actual
symbol and insert it in the string representing the converted number. We leave the detail
of this subalgorithm as an exercise. Figure B.6 shows the main algorithm.


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم