Understanding Number Systems: Binary to Decimal
Understanding Number Systems: Binary to Decimal
Number Systems
By the time you have successfully completed the materials of this chapter, you
will be able to understand the relationships between the following number systems:
® Binary and decimal
@ Binary and hexadecimal
® Decimal and hexadecimal
® Binary and octal
@ Binary and 8421 BCD numbers
if need be. At the moment, it is unclear precisely how written information can
be expressed numerically using 0s and 1s, but we'll discuss that once the binary
system and its operations have been developed.
With those thoughts in mind, we turn to our familiar decimal number sys-
tem, within the framework of which we will familiarize ourselves with the ter-
minology we will employ in the other number systems. You will find that, as we
do so, terms that are familiar in the decimal system will have necessary modifi-
cations to analogous concepts within those other systems.
Our development begins with the introduction of the term base. An alter-
native term used in place of the word “base” is radix, but we will use the word
“base” in this text. The base of any number system is the number of distinct
characters employed for numeration when using that system. For instance, in
our common decimal system, there are 10 symbols we use for numeration: 0, 1,
2, 3, 4, 5, 6, 7, 8, and 9. All numbers within the decimal system are constructed
using those characters. The number of available characters is given as the “base
of the system,’ and hence the decimal system is also referred to as the base-10
number system.
Parenthetically, note that the other number systems use a different set of char-
acters that may be a smaller or larger set than that used in the decimal system.
The binary system, as mentioned previously, employs only the digits 0 and 1, and
therefore the base of that system is 2. It is natural to be puzzled regarding how other
numbers could be depicted using only those two digits, but please be patient! That
bridge will be crossed in the fullness of time, and how we could represent a decimal
number such as 7, for instance, using only 0s and 1s, will be made clear.
When a base- 10 digit is used in combination or series with other such digits,
producing multidigit numbers such as 318, we recognize that each digit occu-
pies a particular place within the number and that it has a unique place value,
.capturing its own meaning. ‘The place value is determined by the location of
the digit relative to the “decimal point.” Here we must be a bit careful, for in dif-
ferent countries different symbols may be used to mark the separation between
integral place values of a number and fractional values. In the United States, for
instance, a dot is used to represent the decimal point, while in Great Britain a
comma is employed. It might be more accurate to refer to the decimal point as a
decimal separator, to avoid confusion, and we will generally adopt that proce-
dure here. That being said, the term “decimal point” is widely in use, and hence
that term will be taken to be synonymous with “decimal separator.”
The decimal separator indicates the line of demarcation between the inte-
gral component of the decimal number and the fractional component. To the
left of the decimal separator we find the integral component of anumber, while
to the right we find the fractional component. You are likely to be familiar with
the place names for the decimal number system, but we will provide an example
as a reminder.
Consider the decimal number 174.3609. ‘The 1 at the start of the number is
said to be in the “hundreds” place, the 7 following it to be in the “tens” place,
and the 4 following that to be in the “ones” place. Digits to the left of the decimal
separator have their place names ending in “s” for all locations. To the right of
the decimal separator, the 3 is said to be in the “tenths” place, the 6 following it
76 Chapter 3
The addition is fairly straightforward, but we will now view it in a rather uncon-
ventional manner. The symmetric property of equality tells us that the equa-
tion can be reversed, yielding
362.19 = S00RT OGae 2 a Uni 0.09
The expression now to the right of the equals sign forms the basis for the ex-
panded form we are intending. Note that the term “expanded” merely refers, in
this case, to a horizontal enlargement of the expression.
Each of the terms on the right side of the equation can be expressed as a
single digit multiplied by a power of 10, in a manner evocative of scientific no-
tation. That is,
382.19 = 300 + 80+ 2+ 0.1 + 0.09
=3x< 10°74 8 & 10° £210) 1 108 OOS 10
This final form is what we refer to as the expanded form. The entire number
is written as a sum of terms, each of which uses a digit from the numeration
system times a power of the base (which is 10 for the decimal number system).
Returning to 174.3609, we can decompose the number into the following sum:
100 + 70 + 4 + 0.3 + 0.06 + 0.000 + 0.0009
Then, proceeding as was done before, we can express the individual terms as a
digit multiplied by a power of 10, obtaining
1x10? +710! +4 x 10° +3 X10 946 X10 -+ 0 < 10 Oecl0
You may be wondering if it is necessary to show the term where the digit is zero.
In the fully expanded form of the decimal number, all the digits from the original
Binary and Other Number Systems 77
number should be shown for the sake of completeness and systematization. Thus,
it would technically be a mistake to suppress that term from the expansion.
BXAMPLE 3.1 Identify the place values for the digits and produce the expanded form of the
decimal number 5,386.724.
SOLUTION
For the digit 5, the place value is 5,000, since the 5 occurs in the thousands
place. For the remaining digits, we can list them systematically:
The place value of 3 is 300, the place value of 8 is 80, the place value
of 6 is 6, the place value of 7 is 0.7, the place value of 2 is 0.02, and the
place value of 4 is 0.004.
The expanded form of the decimal number, using the digits multiplied by pow-
ers of 10, would be
5 ME On esr 07 21238 6102 a6 KOLO Ge 102 2 102 4
We close out this section with a final bit of terminology: in a number repre-
sented in the base-10 system, the digit farthest to the left is referred to as the most
significant digit (MSD), and the digit farthest to the right is referred to as the least
significant digit (LSD). In the preceding illustration, the MSD is 5, while the LSD is 4.
Exercises
Answer each of the following, using complete sentences and proper grammar and spelling.
1. What is meant by the base of a number system, and what alternative
terminology can be used for the word “base”?
2. How do we determine the place value of a digit within a number?
3. What is meant by the expanded form of a decimal number?
4. What, if anything, is the difference between the word base and the word
radix?
In each of the following, identify the place name and place value of every digit.
DB als07 7..0.01879
O28 1.799 8. 10,002.00208
In each of the following, give the expanded form of the decimal number.
9. 874.983 Ve 202.9938
10-7 16:039.177 12. 123,654.92846
For the following, give the decimal number whose expanded form is shown.
13.3 < 10° +0 x 10° 4 10° $3 X 107 2'x 10°F ox 10°
1470 ~ 10-11
8 10
15s 00 Sle One 4108 4 0 + 5 10 +9 X «10°
162551084 9107 1 xX 07+" 9' & 10! + 5X 10° 4+ 3 X 104 +
vad ae
Zo. CGnaorer >
Referencing the problems indicated, for each of the following, identity the LSD and MSD.
17; Problem 5 21. Problem 9
18. Problem 6 22. Problem 10
{o> Problemy, 23Problenia LL
20. Problem 8 24. Problem 12
Give examples of decimal numbers satisfying the following conditions (answers will vary).
25. A whole number having MSD is 5 and LSD is 8.
26. A number having 0s in the tens, hundredths, and thousands places.
Ble
ale
BlAlSPRlMfelMlelAlLel
Cengage
©
2014
Learning
as the decimal separator in Section 3.1 will now be referred to as the binary
point, or the binary separator. The digit occurring immediately to the left of
the binary point has place value 2°, the digit to its left has place value 2', and
so on. The digits to the right of the binary point have place values 27', 2-7, 2-°,
and so on.
Consider the following illustration of a binary number and its interpreta-
tion in our more familiar decimal form: 101101.011,. Using the stated place
values for the binary number and noting that the first digit is in the 2° place
(we can tell this by counting positions to the left of the binary point, keeping in
mind that the initial digit to the left of that point is the 2° position), we obtain
1 0 ee ee Oe ee le eae ae
+i] Meee
T <o?
Converting to decimal form, this would be equivalent to
[peer
S20 Satidah Deeds Ob ahr
aoa aa Lotosl25
= 45.93/93
Shortly, we will formalize the method for conversion between binary and deci-
mal numbers, but before doing so, we present a bit more terminology. The digit
occurring in the highest place position within the number is referred to as the
most significant binary digit, or most significant bit (MSB). The digit with the
lowest place position, on the other hand, is said to be the least significant binary
digit, or least significant bit (LSB). In the example, both the MSB and the LSB
80 Chapter 3
were 1, which is almost always the case in a binary number. The only exception
to this situation would be where the MSB, LSB, or possibly both would be zero.
Because it is common to subdivide binary numbers into nibbles, as an aid
to readability, the preceding example would more likely be encountered as
LOTTO.
The illustration just considered provides an example of how to convert
from binary numbers to equivalent decimal numbers, but we will now formal-
izé that procedure. To convert from the binary to the decimal system, perform
the following steps:
1. Express the binary number in expanded binary form, showing each digit
of the binary number multiplied by an appropriate power of 2.
2. Convert the fractions obtained from the binary places to the right of
the binary point into decimal equivalents (this is not, strictly speaking,
necessary, but it is the convention we will adopt here).
3. Add the resulting decimal numbers together.
Provided that we count our place locations carefully and compute our powers of
2 correctly, the conversion from binary to decimal form is fairly straightforward.
Binary and Other Number Systems 81
427
Ne
82 Chapter 3
could have sufficed; it was not technically necessary to create a column within
which the LSB and MSB were identified, but that practice is both aesthetically
pleasing and informative), with the divisions shown in the left column, the re-
mainders in the second column, and the quotients in the third column. The key
column for our result is the column of remainders, column 2, which we read
upward to produce the binary equivalent of our decimal number.
EXAMPLE
3.4 Convert 167 to binary form.
SOLUTION
Reading upward in Table 3.3, using the remainder column, we obtain the binary
representation of the decimal number 167 as 1010 0111,. Note that we can check
this result to be sure that we have obtained the correct representation by revers-
ing our procedure to move from the binary representation to the decimal form:
Cengage
2014
Learning
©
LX?Y+OxK 2 EP EO KF ee eee
= 128+04+32+0+01+44+2+4+1
= 167
The first two examples have looked only at integral decimal numbers. Now we
will consider the decimal fraction case and make the conversion in that instance to
binary representation. We remark at the outset that finding an exact binary repre-
sentation of such a number is not always possible, for reasons that might be apparent
from the limitations of the method of conversion. First we'll present the method and
then identify for what sorts of decimal numbers the method would fail.
The steps for conversion are as follows:
1. Multiply the decimal fraction by 2.
2. Store the integral part of the product.
Binary and Other Number Systems 83
These values differ by approximately two ten-thousandths and are (for all in-
tents and purposes) equivalent. In approximation, we can use the rule of thumb
that we will triple the number of digits in the binary representation from that of
the decimal representation and maintain the same level of accuracy.
Let’s consider several examples.
.8036 X 2 1
.6072 X 2 1
2144 X 2 0
4288 X 2 0
4304 X 2
4432 X 2
8864 X 2
ai
2014
Learning
Cengage
©
Should a decimal number contain both integral and fractional parts, those
parts should be converted to binary form separately and then combined across
the binary point to obtain the complete binary number.
ml
|
)A
alo
|
|
|=
o};};ol;He
ol;lolK|eK|o oo
SaaS)
Cengage
2014
Learning
©(
Binary and Other Number Systems 85
Step One: We add the binary digits in the right-most column, yielding a
result of 1, which generates no carried value (Table 3.7).
Step Two: Continuing the process in the next column to the left, we add
the carried digit to the other binary digits. Following rule 3 above, the sum
of that column’s entries is 0, with a carry of 1 to the next column to the left
(Table 3.8).
86 Chapter 3
Carry | =
Sum é
Step Three: The process continues, following the stated rules of binary ad-
dition (Table 3.9).
TABLE 3.9 Binary Addition process
Carry 1 1 | 0 | j=
1 1 0 1 1 0. |2
1 0 1 0 1 oe
Stn ~ 0 0 1 |g
Step Four: (Table 3.10).
TABLE 3.10 Binary Addition process
2014
Learning
Cengage
©
Cengage
©
2014
Learning
| 1 0 i 1 QuIg iE]
Difference iy 1 | 0 |
Cengage
©
2014
Learning
Learning
Cengage
©
2014
Learning
Cengage
©
2014
Our difference is the binary number 1 1110), as our work in the equivalent |
decimal representation predicted.
Borrow
Difference
2014
Learning
Cengage
©
Step Two:
Difference
2014
Learning
Cengage
©
Step Three:
Borrow
Difference
Cengage
2014
©
Learning
Binary and Other Number Systems 89
Step Four:
Borrow
Difference
Step Five:
Borrow
Difference
Learning
Cengage
©
2014
2014
Step Six:
Difference
Cengage
©
2014
Learning
You may have observed that in the computations shown to this point, we
have scrupulously avoided the appearance of negative numbers. There is a rea-
son for this, which we should discuss, at least to some degree.
It is common knowledge that negative numbers in base-10 are indicated
by the presence of a “minus sign” preceding the number, and while we could
attempt to introduce similar notation for base-2, this becomes problematic for
our work. The purpose for using binary notation is to ultimately represent al-
ternate states of equipment using Os and 1s, and therefore the use of a third
symbol, such as the minus sign, is an extravagance we cannot afford.
One solution, and one that we shall not explore at this time, is to adopt the
practice that a “sign digit” of 0 or 1, to indicate positive and negative values,
respectively, shall precede every binary number. That is, we could choose to
represent the number “-5” using the binary representation of 5, namely, 101,,
preceded by an extra digit of 1 to indicate that the number is negative.
In our work, this possible resolution to the problem muddies the waters to
an unacceptable degree, and therefore we shall not consider negative binary
numbers at this time. You should simply be aware, for the time being, that there
exist creative solutions to the representation of signed numbers in alternative
bases that do not require the incorporation of the minus sign symbol.
Up to now, we have presented addition and subtraction of binary numbers,
but it is also possible to multiply and divide binary numbers. As we will see,
multiplication proceeds in a manner similar to the method of base-10 multipli-
cations, but that it is actually easier because of the limited possible outcomes for
multiplications of binary numbers.
90 Chapter 3
There are four rules to remember when multiplying binary numbers (rec-
ognizing that these numbers are intended to be base-2 digits):
0x0=0
0Ox1=0
1x0=0
lbxt=1
Consider, using those rules, the multiplication of binary numbers 101, and
11,, following the rules of multiplying and carrying with which we are famil-
iar from base-10 multiplication. Observe that we are actually multiplying the
decimal numbers 5 and 3, so the outcome must be the binary form of 15,
which is 1111,, and that we are constructing the example within a reference
grid (see Tables 3.19 through 3.22), so it is easier to recognize the placement
of the numbers.
TABLE 3.19 Binary Multiplication process
Sopris
ee Oe eee
x 1 1 2014
Learning
Cengage
©
Cengage
© 2014
Learning
Cengage
©
2014
Learning
Now we will add the numbers in the product lines together, obtaining our
final result. Keep in mind the rules for addition of binary numbers and carrying
(Table 3.22).
TABLE 3.22 Binary Multiplication process
1 0 1
x 1 ie
1 0 ay:
1 0 1 ieee
1 1 1 ae ©
Binary and Other Number Systems 91
In a similar way, we can introduce binary division, which again mimics the
process in base-10 but is again easier because of the simplified rules of binary
addition and subtraction. Recall the base-10 procedure directs us to divide the
number constructed from the first sequence of digits in the dividend whose
value is at least as great as the divisor, placing the whole number result in the
quotient. That whole number is multiplied by the divisor, the product placed
beneath the dividend, and we subtract.
Following this, the next digit in the dividend is brought down, and we it-
erate the process until the outcome of the subtraction becomes less than the
divisor and no further digits can be brought down from the dividend, at which
time the division process terminates. The final difference is referred to as the
remainder of the division.
Consider the following example, which demonstrates that the process in the
binary number system is analogous.
The “10” in the final line, being less than the divisor, must be our remainder,
and hence our result is 11,, with remainder 10).
In decimal form, the problem was to divide 11 by 3, and thus our
binary result should be equivalent to a quotient of 3, with remainder 2. A
quick conversion of the binary result shows that this is precisely what we
obtained.
92 Chapter 3
EXCAR PEE S13 Express the statement “It was a dark and stormy night. in binary form.
SOLUTION
We begin by considering the table relating the ASCII symbols and their binary
equivalents. We only need to locate the bytes representative of the individual
characters, maintaining an awareness that “I” is not to be confused with “i” for
the purpose of encryption. As we can see from the chart, the representation of
Binary and Other Number Systems 93
ae ) Sn
010 1001 I 100 1001 110 1001
? 010 1010 J 100 1010
” 0101011 k 110 1011
0 o110000 =|P|
= 101 0000
1 011 0001 pf 111 0001
2 011 0010 R 101 0010
3 011 0011 S 101 0011
4 011 0100 i 101 0100 111.0100
5 0110101 U 101 0101
6 011 0110 Vv 101 0110
| 7 0110111 Ww 101 0111 w
8 011 1000 x 101 1000 x 111 1000
9 011 1001 Y 101 1001 y 111 1001
011 1010 Z 101 1010 ; 111 1010
as 011 1011 1011011 { 111 1011
F < 011 1100 \ 101 1100 | 111 1100
= 011 1101 101 1101 111 1101
> 011 1110 A 101 1110 : 1111110
a 2 ting = 101 1111 (del) } 11111 Cengage
©
2014
Learning
94 Chapter 3
“I” is 0100 1001, and from there we can proceed to obtain all the binary repre-
sentations, with the following result:
Exercises
For each of the following problems, answer in complete sentences, using proper spelling
and grammar.
Perform the following binary subtractions. Check your work by converting minuend, sub-
trahend, and difference to decimal form and subtracting these to show that the same result is
obtained.
26. 1101, — 1011, 28. 1001 1101, — 101 1100,
27. 110,— 11, 29. 11.0111,— 1.1,
Perform the following binary multiplications. Check your work by converting the factors and
the product to decimal form and multiplying these to show that the same result is obtained.
30. (1101,)(101,) svar aieyG als
31. (10 1101,)(110,) 33. (1001,)(1010,)
Perform the following binary divisions. Check your work by converting the dividend, divisor,
and quotient to decimal form and dividing these to show that the same result is obtained.
34. 101101, + 1001, 36. 10000100 1101, = 1 0001,
Som VDOT So WIE 37. 1000 0010 0000, = 10 0000,
EXAMPLE 3.14 Convert the binary digit 11 0110 1111 0110, to hex.
SOLUTION
Using the methods for conversion to decimal numbers, we can show that this num-
ber is 14070 in base-10, but this is not relevant for our exercise here. If we expand the
first nibble to include two 0s preceding the 1s, we obtain the equivalent form:
0011 0110 1111 0110,
Now we'll replace each nibble by the hex number determined from the table
above. This yields
36F61.
This is truly astonishing, assuming that it is true. We will now confirm its
accuracy.
As was done with binary numbers, we can use powers of the base to convert
hex numbers to our familiar decimal form. That is, if we have a number such
as 36F6,,, we can use the powers of 16 to convert the number to base-10. This
illustration will serve to verify the result obtained in the previous example:
This is precisely what we had indicated was the decimal equivalent to the binary
number 11 0110 1111 0110,, and this indicates that our method for conversion
is accurate.
Conversion from hex to binary is the exact inversion of the procedure, with
the hex digits replaced, in order, by the related nibbles of binary information.
BA085,,
= 11 X 16°+ 10 X 166+ 0X 167+ 8X 16'+5x 16°
= 720896 + 40960 +0 + 1284+ 5
= 761989
1011.1010.0000.1000 0101, = 2)? 4.27 -o' = eee a7
= 524288 + 131072 + 65536 + 32768 + 8192
+128+4+1
= 761989
Binary and Other Number Systems 99
As in the explanation above, we construct the expanded form of the hex number,
utilize the powers of 16, and simplify to obtain our result:
BA085,,= 11 X 16*+ 10 X 16° + 0 X 167+ 8 X 16'+5 x 16°
= 720896 + 40960 + 0+ 128+ 5
= 761989
SOLUTION
The hex equivalent is constructed using the remainders, read upward through
the column: 3A8,, (Table 3.26).
| Remainderas | Remainder | |
Division _DecimalNumber___asHex Quotient|
2014
Learning
gage
Cer
SOLUTION
Having reached a quotient of 0, we obtain our number in hex form, using the
remainder as hex column, read upward: 1CA3BB,, (Table 3.27).
In the case of decimal fraction numbers, we follow the algorithm we devel-
oped in the binary case, multiplying repeatedly by 16 and keeping track of the
integral part of the products.
100 Chapter 3
Remainder as Remainder
DIMEola DY=Yotlaatel@elaal ex=16 as Hex (@]Ureld(=laie
ieewieearst 117307,
7331-= 16 2 458
458 = 16 A 28
28
=~ 16 12 €
Leel6 1 Cengage
©
2014
Learning
As was the case for binary representations, we list the steps as follows:
1. Multiply the decimal fraction by 16.
2. Store the integral part of the product and convert it to hex form, if needed.
3. Repeatedly multiply the remaining decimal fraction by 16 at each stage
of the process. Continue until the fractional part becomes 0.
4. The integral parts (in hex form) of the products, when read in order and
placed after the hex separator, yield the equivalent hex number.
Hal<=te]¢-]@erclas faltsteleclt
as Decimal Part as Decimal
Multiplication Number Hex Fraction
000202026367188 X 16 |
=o «| «003232421875
003232421875 X 16 | 0 «| «05171875
5PM)
Cengage
©
2014
Learning
You are probably aware that your computer monitor uses the primary colors of
light (red, green, and blue) to display all other possible colors. The device uses
different intensities of each primary color, combines them, and concentrates
them onto a pixel (picture element) of the screen. The colors range from white
(in which 100% of red, green, and blue are displayed in the pixel) to black (in
which 0% of red, green, and blue are displayed).
HTML manages the RGB combinations by using six-digit hex numbers,
called color codes. The color code designation begins with a pound symbol (#)
followed by the hex number, which is actually a combination of three two-digit
hex numbers denoting RGB intensities. These allow you to set the red, green, and
blue values of a color, and the combination of the relative strengths of the indi-
vidual colors produces the color desired. The greatest intensity of any particular
one of the individual primary colors is FF, which has decimal equivalent 255.
For instance, the color orange can be produced by an intense application of
red and a mildly strong green, combined with a relatively weak application of blue.
The color code for orange is #FF8040, which denotes the strongest (FF) possible
red, a strong but not overly powerful (80) green, and a fairly weak blue (40).
Exercises
Answer the following questions in complete sentences, using correct spelling and grammar.
1. In your own words, explain the process of converting binary numbers to
hexadecimal form.
2. In your own words, explain the process of converting hexadecimal num-
bers to binary form.
102 Chapter 3
BAA MPLE 3 42.0 Convert the decimal number 1762 to octal form.
SOLUTION
As was done before, we use a tabular approach in Table 3.30 to make the process
both systematic and well organized. Reading the remainders (as octal numbers)
in reverse order, we obtain the octal equivalent to 1762 as 3342s.
~
Remainderas | Remainder
as —
Division |DY=Yeol |aat-](01a)
ek=] qmmn @Xeie-]
6 ]aa]el—] ame @ LUlold(—lale
1762 5 8
220 = 8 2
27=8
348 ©Cengage
SOLUTION
Having reached a quotient of 0, the process terminates, and we can read our
base-8 representation as 1033533, (Table 3.31).
©Cengage
Learr
(in octal form) until the fractional part of the number is 0. The octal form of
the number is then obtained by reading the integral part of the product in
advancing order and appending a base-8 subscript.
e
ee ee ee ee
T ee
Cengage
©
2014
Learning
As we saw with the other bases, if the decimal number were to be a combi-
nation of integral and decimal fraction parts, we would obtain the base-8 equiv-
alences independently and then combine the results. Such an illustration will be
left for you to attempt in the exercises.
You might be wondering why the base-10 decimal fraction numbers seem to
often generate repeating decimal representations in base-2, base-8, and base-16,
and this is a question worthy of investigation. The answer has to do with the fact
that all the digits to the right of the binary, hex, and octal separators are powers of
2 and have no other prime factors. A decimal number such as .1, which we saw in
the base-2 section has a nonterminating binary equivalent, has fraction form 1/10,
the denominator of which is not a power of 2, and has a prime factor of 5. Such
numbers will always have nonterminating decimal equivalents in the bases we
have examined because of this relationship between the denominators.
For base-8, each of the eight octal digits is equivalent to a three-digit binary
number, and the translation between octal and binary forms merely requires
that (for translation from binary to octal) the three binary digits be replaced by
their octal equivalent. Conversion from octal to binary is the precise inversion
of that procedure.
Before viewing some examples, let’s produce the equivalencies for our refer-
ence in Table 3.33.
TABLE 3.33 Equivalencies between decimal, binary, and octal numbers
tol sala 1
EXAMPLE 3:23 Convert the binary number 11 0101 1101 1001 1111, to octal form.
SOLUTION
In order to make the conversion more obvious, we will begin by reorganizing
our binary number, divided into nibbles (as is the common practice) so that its
digits are in clusters of three: 110 101 110 110 011 111,.
Next, referencing the table of equivalencies, we will replace each grouping
of three binary digits into its octal equivalent. That the number is octal will be
indicated, as usual, by the appended subscript of 8 at the end of the representa-
tion: 656637..
EXAMPLE 3.24 Convert the binary number 1 0110 1011 1001, into octal form.
SOLUTION
In this case, note that the binary number contains 13 digits, and thus re-
organization into groups of three cannot be done with the number in its
present form. You may recall that this issue was encountered in our con-
sideration of hex numbers, and it was decided that we would incorporate
enough preceding 0s to allow for the subdivision into groups required. The
smallest multiple of 3 that is greater than 13 is 15, and hence we must in-
clude two preceding 0s to our number and then perform the reallocation of
digits into sets of three:
001 011 010 111 001,
oe
ee eee
EXAMPLE 3.25 — Convert the octal number 7321, to binary form.
SOLUTION 7
Each of the octal digits is replaced by its binary equivalent, yielding
111 011 010 001,
In order to maintain our practice of exhibiting binary digits broken into nib-
bles, we reorganize this expression in groups of four digits, obtaining 1110
1101 0001).
Exercises
Answer the following questions using complete sentences, with correct spelling and grammar.
1. What is the difference between binary numbers and octal numbers?
2. What is the process for converting binary numbers to octal numbers?
3. What is the process for converting octal numbers to binary numbers?
Convert the following decimal numbers to octal form.
4, 133 626135
5. 2984 PROQS T/L 25
for which we know the basis. Note that this is not the same as representing the
complete decimal number in its equivalent binary form—far from it! The code
translates the individual decimal digits into their binary equivalents, displaying
the number in a string of nibbles. The representations of the digits are shown in
Table 3.34 as a reminder of our past work: because we are using nibbles to rep-
resent the 10 decimal digits and there are 2* = 16 actual nibbles possible, there
are six nibbles that are considered invalid in 8421 BCD code.
2014
earning
©Cengage
L
Note that when a decimal number is represented in BCD code, the sub-
script of 2, denoting the base-2 representation of a decimal number, is not used.
That is, if we wanted to represent the decimal number 368 in BCD, we would
have the representation as 0011 0110 1000, and there would be no subscript of
2 at the end of the string of nibbles.
A code such as 8421 BCD is referred to as a weighted code, which means
that the representation of the base-10 digits is performed using a four-bit com-
bination for which each position within the nibble carries a particular weight of
8, 4, 2, or 1. That is, when we give a nibble of BCD code, such as 1001, the first
digit carries a place weight of 8, the second a place weight of 4, the third a place
weight of 2, and the final a place weight of 1. Because this is precisely the man-
ner in which the first four places of binary numbers were defined, this terminol-
ogy may seem a bit superfluous, but there are other BCD codes, such as 2421
BCD, for which the place weights are not the same as binary representation of
decimal numbers. In that code, the nibble 1101 would be the representation of
the decimal digit 7 because (in expanded form) it is equivalent to 1 x 2 + 1 X
AcOX 2X LS
In some texts, there is an effort to make explicit the point that a string of
nibbles is representative of a decimal number in BCD code by appending a
subscript of BCD where one would typically see the base identifier. That is, the
BCD representation of the decimal number 368 could be given as 0011 0110
1000,¢p, but we will (in this text) ensure that the use of BCD representation is
clear by context and will not employ that notation.
108 Chapter 3
ae ea ee re ee
EXAMPLE 3.26 — Compare the binary representation of the decimal number 843 to the 8421
BCD code for that number.
SOLUTION
This is a good time to review our method for conversion of decimal numbers to
binary form: divide the number repeatedly by 2, keeping track of the remain-
ders and proceeding until the quotient of the division process becomes 0. The
remainders, read in reverse order, form the binary equivalent to the decimal
number (Table 3.35). The binary representation of the decimal number 843 is
11.0100 1011).
TABLE 3.35 Converting 843 to binary
Cengage
©
2014
Learning
The BCD code representation of the decimal number 843 will consist of the
coded representations of the individual digits 8, 4, and 3. Referring to our chart
or recalling the base-2 representation for each digit, we obtain 1000 0100 0011.
Note that the two results are completely unrelated to one another, and this rein-
forces our admonition that the two processes are extremely different.
A decimal number encrypted using 8421 BCD code can be decoded into
its decimal equivalent by replacing every nibble in the code by the appropriate
digit, which we can either obtain from the table given earlier or by translating
each nibble individually back to base-10.
EXAMPLE 3.27 _ Find the decimal number represented by the BCD code 0010 1001 0111 0101.
SOLUTION
We can recognize the nibbles as being the binary equivalents to 2, 9, 7, and 6,
respectively, and therefore the equivalent decimal number would be 2976.
EXAMPLE 3.28 _ Find the decimal number represented by the BCD code 0010 1101 0001 0101.
SOLUTION
Proceeding as in the previous example, we find that the decimal equivalents of
the individual nibbles would be 2, 13, 1, and 5. Observe that the second of these,
Binary and Other Number Systems 109
1101, does not represent a single digit but rather is equivalent to the decimal
number 13; thus, this BCD code is not a possible representation for a decimal
number. Recall that, earlier, we had indicated that there were six nibbles consid-
ered to be invalid in 8421 BCD code, and this is one of them.
The examples given to this point have all been integral valued, but BCD
code can be used for decimal fraction numbers as well. We simply convert the
digits before and after the decimal point to their BCD equivalents and place a
separator point in the decimal point’s position.
BXAMPLE 3.29 Give the BCD form of the decimal number 193.482.
SOLUTION
Referring once more to our table of BCD equivalents for the decimal digits, we
obtain the following representation:
0001 1001 0011.0100 1000 0010
All the codes discussed so far have been weighted codes, but there certainly
are nonweighted codes as well. Two examples of these are Excess-3 (XS-3)
code and Gray codes. The former can be used for arithmetic operations, the
latter for mechanical switching systems.
Full exploration of these codes would take us yet farther afield, but Gray
codes are sufficiently interesting that we will spend a brief time considering
them. The code type is named in honor of the creator of its first iteration, Frank
Gray of Bell Labs. Note that the source of the code type is the name of the inven-
tor, and therefore it would be grammatically incorrect to use any of the other
possible spellings of the word Gray (such as “gray” or “grey,” for instance).
The difficulty with using binary codes applied to switching systems is this: if
a device were to indicate position by opening and closing switches, where open
and closed are represented by 1 and 0, respectively, then two adjacent positions
(011 and 100, for example) are such that the transition between one position
and the next would require the transition of three switches synchronously. In
the moment of transition, all three switches will be changing at a slightly dif-
ferent rate, and this could spawn misleading readings for an observer. It would
be highly desirable for successive states to be represented by strings of binary
numbers that have minimal differences, such as (in an ideal case) variation of
only a single bit. A code capable of representing a succession of integer values
possessing this quality is referred to as a Gray code.
There is no single Gray code; rather, the name applies to any code that
represents each number in a sequence of integers (from 0 through 2” — 1,
inclusive) as a string of binary digits of length n, such that strings that differ
only in one bit represent adjacent integers in the sequence. The rationale for this
construction is that advancing through the list of integers requires changing, or
flipping, the value of one bit at a time.
One method of constructing a Gray code to represent, for example, the
integers from 0 through 15, inclusive, offers an interesting exercise, which we
shall leave to you. One starts with a string of four Os (we use four digits because
we know that there are 16 possible strings of four binary digits) and then suc-
cessively flip the rightmost bit that produces a completely new string of digits.
When we're through, we will (hopefully!) have 16 distinct sets of four binary
digits to which we can assign the numbers 0 through 15. The set will, by con-
struction, satisfy the definition of what it means to be a Gray code.
A second method is a process of reflecting and prepending; we will dem-
onstrate the process here, since it is less intuitive than the method already de-
scribed. The point is that there are many ways of constructing Gray codes rather
than a single canonical process.
Our procedure will be to start with the digits 0 and 1, “mirror” those dig-
its (“prepend” 0 to the first half and 1 to the last half of digits on the list), and
then iterate the process until the desired number of digits (in this case, 16) is
obtained. That may sound a bit complicated, but you'll find that it is, in practice,
fairly easy.
Step One: Begin with the digits 0 and 1 and mirror that set:
e 0, 1, 1, 0 (note that “mirroring” merely means to repeat the digits in re-
verse order)
Step Two: To the first half of strings on that list, prepend 0; to the second
half of strings on the list, prepend 1:
« 00701 11,10
Step Three: Mirror the set once more:
2100501 -11410,.10,.1 15 015,00
Step Four: Prepend 0s to the first half of strings and 1s to the second half
of strings:
e000; 000 011 OTO M1105 TEE OT sro0
Step Five: Mirror the set once more (this will produce a set of 16 strings):
«000; 001; 01, O10 LO, 111) LOTAOOR LOO TOTS IT 1102 010; OMS 001000
Step Six: Prepend 0s to the first half of strings and 1s to the second half of
strings:
e (0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100, 1100, 1101, 1111, 1110,
1010, 1011, 1001, 1000
Observe there are no repetitions on the list and that each string differs from
its predecessor in a single bit. We could thus make a unique assignment of the
decimal numbers from 0 through 15, inclusive, to these binary strings, in order.
Exercises
Answer the following questions using complete sentences, with correct spelling and grammar.
1. What is meant by a BCD code?
2. What is meant by a weighted code?
3. What is a Gray code?
Binary and Other Number Systems 111
In the following problems, convert the decimal numbers to binary form and then give the 8421
BCD representation of the number.
4. 54 6. 347.625
5. 6666 7 0010
In the following problems, convert the 8421 BCD representations to the equivalent decimal
number.
8. 1001 01110101 10. 1001.0111 0011
9. 01110101 1001 0011 0001 LL, 0111,0011.1001
In this section, we examined the 8421 BCD weighted code, but there exist other weighted codes,
such as the 2421 BCD code. The development of the code is similar to that of 8421 BCD, but
the weights are, 2.4, 2, and 1 respectively. The following are 2421 BCD representations of
decimal numbers. Find the decimal numbers with the shown representations.
120001 OUT iAT0 0011 14, 1111.1110 1011 0010
13. 0101 0001 1111.1100 1101 15. 0000.0011 0100 1110
Summary
In this chapter, you learned about:
© 'The decimal, binary, and hexadecimal number systems.
© The arithmetic operations and applications of the binary number system.
© The relationship between binary and hex, decimal and hex, and binary
and octal.
© The binary and 8421 codes.
Glossary
ASCII (American Standard Code for Information base-16 number system A system of numeration
Interchange) An encryption device for the English al- _ using 16 distinct symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,
phabet using binary numbers. B, C, D, E, and EF. Also called the hexadecimal number
BCD (binary-coded decimal) code Any of the codes hexadecimal point The analog to the decimal point in
used to express the decimal digits (0 through 9) using base-16; the point of demarcation between the whole
a nibble. number and fractional parts of a base-16 number. Also
called the hexadecimal separator.
binary number system Also called base-2, a numera-
tion system in which all numbers are represented using hexadecimal separator The analog to the decimal
the digits 0 and 1 only. point in the hexadecimal number system.
binary point The analog to the decimal point in base- least significant binary digit (LSB) The base-2 in-
10; the point of demarcation between the whole num- stance of the least significant digit. Also called the least
ber and fractional parts of a binary number. Also called significant bit.
the binary separator. least significant digit (LSD) The nonzero digit farthest
binary separator The analog to the decimal separator right within a number's representation.
in the binary system. Also called the binary point. most significant binary digit (MSB) The base-2 in-
bit A two-digit pairing in the binary number system. stance of the most significant digit. Also called the
most significant bit.
byte An eight-bit grouping in the binary number
system. most significant digit (MSD) The nonzero digit far-
thest left within a number’s representation.
color codes Six-digit hex number HTML designations
that identify the text color in a document. nibble A four-bit grouping in the binary number
system.
decimal number system A system of numeration us-
ing 10 distinct symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. nonweighted codes: Codes that employ a weighted
positioning system.
decimal separator A dot used to indicate the separa-
tion from whole number to fraction number places octal number system Also called base-8, a numeration
within a number's base-10 representation. system in which all numbers are represented using the
symbols 0, 1, 2, 3, 4, 5, 6, and 7 only.
8421 BCD code The particular binary decimal code
using the binary equivalents of the numbers 0 through octal separator The analog to the decimal point in the
9 as the encryption code. octal number system.
Excess-3 (XS-3) codes A BCD code and numeral sys- place value The value associated with a particular digit
tem using a prespecified value N as a bias value. location in a numerical representation.
expanded form The decomposition of a number as a radix The base of a number system.
sum where each term displays a product of a digit of
RGB The red/green/blue ratios used to construct colors
the number's representation with its place value.
in HTML; also called color codes.
exploded form Another term for the expanded form of
symmetric property of equality The property stating
a number.
that A = B is equivalent to B = A.
Gray codes A binary numeral system where two suc-
weighted code a code in which representation of the
cessive values differ only in one bit.
base-10 digits is performed using a four-bit combina-
hexadecimal number system Also called base-16, a tion for which each position within the nibble carries a
numeration system in which all numbers are repre- particular weight.
sented using the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B,
C, D, E, and F only.
Binary and Other Number Systems 113
End-of-Chapter Problems
In each of the following, identify the place name and place value of every digit.
1. 4527 89 OLZ/A.o
2. 346.567
In each of the following, give the expanded form of the decimal number.
4. 1954.37 6. 883.5678
2 O6.238
For the following, sive the decimal number whose expanded form is shown.
704% 10° +2 x 10° +6 < 10-40 X 10°F § 10 6 x10
8. 5x 10°+3x10'+9x107+4xX 10°
9. 3 X 10° +8 X 10*+ 0 X 10° +0107 + 5 x 10° + 4 x 10°
For each of the following, identify the LSD and MSD.
10. 4527.89
Dits-336200
IDPS G103 X10 9210
tae eae
Give examples of decimal numbers satisfying the following conditions.
13. A whole number having an MSD of 4 and an LSD of 7.
14. A number having 9s in the tenths, hundreds, and thousandths places.
For each of the following decimal numbers, convert to binary form.
15. 5249 Meme bye
Perform the following binary additions. Check your work by converting the addends and sum to
decimal form and adding these to show that the same result is obtained.
19% Jett 1 10005 20. MOLTO ta L0OL 0001,
Perform the following binary subtractions. Check your work by converting minuend, sub-
trahend, and difference to decimal form and subtracting these to show that the same result is
obtained.
ZS lOO) Waa LU 22 eT OMe be Ls
Perform the following binary multiplications. Check your work by converting the factors and
the product to decimal form and multiplying these to show that the same result is obtained.
23. (1 1000,)(110,) 24. (111,)(1000,)
Perform the following binary divisions. Check your work by converting the dividend, divisor,
and quotient to decimal form and dividing these to show that the same result is obtained.
25. 1000 0001, = 111, 26. 1000 0100 1100, + 1 0010,
114 Chapter 3
In the following problems, convert the decimal numbers to binary form and then give the 8421
BCD representation of the number.
45,255 46. 97.625
In the following problems, convert the 8421 BCD representations to the equivalent decimal
number.
47. 0001 1001 0101 0100 48. 0011 0111.0101 0110
In the following problems, convert the 2421 BCD representations to the equivalent decimal
number.
49. 1111 0111.1110 0100 0101 50. 1000 0111 1100 1111 1110 0001