CH09 Number Systems
CH09 Number Systems
William Stallings
Computer Organization
and Architecture
9th Edition
+ Chapter 9
Number Systems
+
The Decimal System
System based on decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to represent
numbers
83 = (8 * 10) + 3
The number 4728 means four thousands, seven hundreds, two tens, plus
eight:
83 = (8 * 101) + (3 * 100)
The same principle holds for decimal fractions, but negative powers of 10 are used.
Thus, the decimal fraction 0.256 stands for 2 tenths plus 5 hundredths plus 6
thousandths:
A number with both an integer and fractional part has digits raised to both positive
and negative powers of 10:
+ (6 * 10-3)
( . . . a3a2a1a0.a-1a-2a-3 . . . )r
The digits 1 and 0 in binary notation have the same meaning as in decimal notation:
02 = 010
12 = 110
To represent larger numbers each digit in a binary number has a value depending on its
position:
and so on. Again, fractional values are represented with negative powers of the radix:
Decimal notation to
binary notation:
Integer and fractional parts are
handled separately
Converting Between
Binary and Decimal
For the integer part, recall that in binary notation, an integer represented by
bm-1bm-2 . . . b2b1b0 bi = 0 or 1
N = 2 * N1 + R0 R0 = 0 or 1
Next, we divide the quotient N1 by 2. Assume that the new quotient is N2 and the new
remainder R1. Then
N1 = 2 * N2 + R1 R1 = 0 or 1
so that
N2 = 2N3 + R2
we have
Continued . . .
N = (N3 * 23) + (R2 * 22) + (R1 * 21) + R0
Because N >N1 > N2 . . . , continuing this sequence will
eventually produce a quotient Nm-1 = 1 (except for the
decimal integers 0 and 1, whose binary equivalents are 0 and
Integers
1, respectively) and a remainder Rm-2, which is 0 or 1. Then
Examples of Converting
from Decimal Notation
to Binary Notation for
Integers
For the fractional part, recall that in binary notation, a
number with a value between 0 and 1 is represented by
Fractions
0.b-1b-2b-3 . . . bi = 0 or 1
and has the value
(b-1 * 2-1) + (b-2 * 2-2) + (b-3 * 2-3) . . .
This can be rewritten as
2-1 * (b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . ))
Suppose we want to convert the number F (0
< F < 1) from decimal to binary notation. We
know that F can be expressed in the form
+
F = 2-1 * (b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . ))
If we multiply F by 2, we obtain,
2 * F = b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . )
Continued . . .
From this equation, we see that the integer part of (2 * F),
which must be either 0 or 1 because 0 < F < 1, is
simply b-1. So we can say (2 * F) = b-1 + F1, where 0 < F1 Fractions
< 1 and where
F1 = 2-1 * (b-2 + 2-1 * (b-3 + 2-1 * (b-4 + . . . ) . . . ))
To find b−2, we repeat the process.
At each step, the fractional part of the number from the
previous step is multiplied by 2. The digit to the left of
the decimal point in the
product will be 0 or 1 and contributes to the binary
representation, starting with the
most significant digit. The fractional part of the product is
+ used as the multiplicand
in the next step.
Examples of Converting
from Decimal Notation
to Binary Notation for
Fractions
+
Hexadecimal Notation
Binary digits are grouped into sets of four bits, called a nibble
Because 16 symbols are used, the notation is called hexadecimal and the 16
symbols are the hexadecimal digits
Thus
Chapter 9
Convertingbetween
The decimal system binary and decimal
Integers
Positional number Fractions
systems
Hexadecimal notation
The binary system