Number Systems
After completing this lecture, you will be able to:
• Define the decimal, binary, octal, and hexadecimal numbering systems
and be able to convert from one numbering or coding system to another
• Define the terms bit, byte, word, least significant bit (LSB), and most
significant bit (MSB) as they apply to binary memory locations
• Add, subtract, multiply, and divide binary number
Types of Number System
Decimal System
The decimal system, which is most common to us, has a base of 10. The radix or base of
a number system determines the total number of different symbols or digits used by that
system. For instance, in the decimal system, 10 unique numbers or digits—i.e., the digits
0 through 9 are used: the total number of symbols is the same as the base, and the
symbol with the largest value is 1 less than the base.
The value of a decimal number depends on the digits that make up the number and the
place value of each digit. A place (weight) value is assigned to each position that a digit
would hold from right to left. In the decimal system the first position, starting from the
rightmost position, is 0; the second is 1; the third is 2; and so, on up to the last position.
The weighted value of each position can be expressed as the base (10 in this case) raised
to the power of the position.For the decimal system then, the position weights are 1, 10,
100, 1000, and so on. Figure 1 illustrates how the value of a decimal number can be
calculated by multiplying each digit by the weight of its position and summing the
results.
Fig. 1 Weighted value in the decimal system
Binary System
The binary system uses the number 2 as the base. The only allowable digits are 0 and
1. With digital circuits it is easy to distinguish between two voltage levels (i.e., +5 V
and 0 V), which can be related to the binary digits 1 and 0 (Figure 2). Therefore, the
binary system can be applied quite easily to computer systems. Since the binary
system uses only two digits, each position of a binary number can go through
only two changes, and then a 1 is carried to the immediate left position.
Fig. 2 High and Low levels
Table shows a comparison among four common number systems: decimal (base 10), octal
(base 8), hexadecimal (base 16), and binary (base 2). Note that all numbering systems
start at zero.
Table: 1
The decimal equivalent of a binary
number can be determined in a manner
similar to that used for a decimal
number. This time the weighted values
of the positions are 1, 2, 4, 8, 16, 32,
64, and so on. The weighted value,
instead of being 10 raised to the power
of the position, is 2 raised to the power
of the position.
Figure 3 illustrates how the binary number 10101101 is converted to its decimal
equivalent: 173.
Each digit of a binary number is known as a bit.
In a
processor-memory element consists of hundreds
or thousands of locations. These locations, or
registers, are referred to as words. Each
word is capable of storing data in the form
of binary digits, or bits.
Bits can also be grouped within a word into
bytes.
Fig. 3 Converting a binary number to a
A group of 8 bits is a byte, and a group of 2
decimal number or more bytes is a word. Figure 4 illustrates
a 16-bit word made up of 2 bytes. The least
significant bit (LSB) is the digit that
represents the smallest value, and the most
significant bit (MSB) is the digit that
Fig. 4 A 16-bit word.
represents the largest value. A bit within
the word can exist only in two states: a
To convert a decimal number to its binary equivalent, we must perform a series of
divisions by 2. Figure 5 illustrates the conversion of the decimal number 47 to binary. We
start by dividing the decimal number by 2.
If there is a remainder, it is placed
in the LSB of the binary number. If
there is no remainder, a 0 is placed
in the LSB. The result of the division
is brought down and the process is
repeated until the result of
successive divisions has been
reduced to 0.
Fig. 5 Converting a decimal number to a binary
number
Negative Numbers
2
If a decimal number is positive, it has a plus
sign; if a number is negative, it has a minus
sign. In binary number systems, such as
computers, it is not possible to use positive
and negative symbols to represent the polarity
of a number. One method of representing a
binary number as either a positive or
negative value is to use an extra digit, or
sign bit, at the MSB side of the number. In the
sign bit position, a 0 indicates that the
number is positive, and a 1 indicates a
Another method of expressing a negative number in a digital system is by using the
complement of a binary number. To complement a binary number, change all the 1s to 0s
and all the 0s to 1s. This is known as the 1’s complement form of a binary number. For
example, the 1’s complement of 1001 is 0110. The most common way to express a
negative binary number is to show it as a 2’s complement number. The 2’s
complement is the binary number that results when 1 is added to the 1’s
complement. This system is shown in Table 3. A zero sign bit means a positive
number, whereas a 1 sign bit means a negative number. Using the 2’s complement
makes it easier for the computer to perform mathematical operations. The correct
sign bit is generated by forming the 2’s complement.
The computer knows that a number retrieved from memory is a negative number if the
MSB is 1. Whenever a negative number is entered from a keyboard, the computer
stores it as a 2’s complement. What follows is the original number in true binary
followed by its 1’s complement, its 2’s complement, and finally, its decimal equivalent
Octal System
To express the number in the binary system requires many more digits than in the
decimal system. Too many binary digits can become cumbersome to read or write. To
solve this problem, other related numbering systems are used. The octal numbering
system, a base 8 system, is used because 8 data bits make up a byte of
information that can be addressed. Octal is a convenient means of handling
large binary numbers
As shown in Table 4, one octal digit can be used to express three binary digits. As in all
other numbering systems, each digit in an octal number has a weighted decimal value
according to its position. Figure 6 illustrates how the octal number 462 is converted to its
decimal equivalent: 306.
Fig. 6 Converting an octal number to a decimal
number
Octal converts easily to binary equivalents. For example, the octal number 462 is converted
to its binary equivalent by assembling the 3-bit groups, as illustrated in Figure 7.
Fig. 7 Converting an octal number to a binary number
Hexadecimal System
The hexadecimal (hex) numbering system is used in programmable controllers because a
word of data consists of 16 data bits, or two 8-bit bytes. The hexadecimal system is a
base 16 system, with A to F used to represent decimal numbers 10 to 15 (Table 5). The
hexadecimal numbering system allows the status of a large number of binary bits to be
represented in a small space, such as on a computer screen.
The techniques used when converting hexadecimal to decimal and decimal to
hexadecimal are the same as those used for binary and octal. To convert a
hexadecimal number to its decimal equivalent, the hexadecimal digits in the
columns are multiplied by the base 16 weight, depending on digit significance.
Figure 8 illustrates how the conversion
would be done for the hex number 1B7
Fig. 8 Converting a hexadecimal number to a binary
number
Hexadecimal numbers can easily be converted to binary numbers. Conversion is
accomplished by writing the 4-bit binary equivalent of the hex digit for each
position, as illustrated in Figure 9
Fig. 9 Converting a hexadecimal number to a binary
number
Binary Arithmetic
Mathematical operations include addition, subtraction, multiplication, and division.
Binary addition follows rules similar to decimal addition. When adding with binary
numbers, there are only four conditions that can occur:
The first three conditions are easy because they are like adding decimals, but the last
condition is slightly different. In decimal, 1 + 1 = 2. In binary, a 2 is written 10.
Therefore, in binary, 1 + 1 = 0, with a carry of 1 to the next most significant place value.
When adding larger binary numbers, the resulting 1s are carried into higher-order
columns, as shown in the following examples.
In arithmetic functions, the initial numeric
quantities
that are to be combined by subtraction are the
minuend
and subtrahend. The result of the subtraction
process is
called the difference, represented as:
To subtract from larger binary numbers, subtract
column by column, borrowing from the adjacent
column when necessary. Remember that when
borrowing from the adjacent column, there are
now two digits, i.e., 0 borrow 1 gives 10.
Binary numbers can also be negative. The
procedure for this calculation is identical to
that of decimal numbers because the smaller
value is subtracted from the larger value and a
negative sign is placed in front of the result.
There are other methods available for doing subtraction:
1’s complement
2’s complement
The procedure for subtracting numbers using the 1’s complement is as
follows:
Step 1 Change the subtrahend to 1’s complement.
Step 2 Add the two numbers.
Stepthere
When 3 Remove theat last
is a carry carry
the end of and add it to the number (end-around
carry)
the result, the result is positive.
When there is no carry, we take the
1’s complement of the result is and
a minus sign has to be placed in
front of it.
For subtraction using the 2’s complement,
the 2’s complement is added instead of
subtracting the numbers. In the result, if
the carry is a 1, then the result is
positive; if the carry is a 0, then the
result is negative and requires
a minus sign.
REVIEW QUESTIONS
1. Convert each of the following binary 2. Convert each of the following decimal
numbers to numbers to
decimal numbers: binary numbers:
a. 10 a. 7
b. 100 b. 19
c. 111 c. 28
d. 1011 d. 46
e. 1100 e. 57
f. 10010 f. 86
g. 10101 g. 94
h. 11111 h. 112
i. 11001101 i. 148
j. 1110001 j. 230
3. Convert each of the following octal numbers to 4. Convert each of the following octal numbers to
decimal numbers: binary numbers:
a. 36 a. 74
b. 104 b. 130
c. 120 c. 250
d. 216 d. 1510
e. 360 e. 2551
f. 1516 f. 2634
5. Convert each of the following hexadecimal 6. Convert each of the following hexadecimal
numbers to decimal numbers: numbers to binary numbers:
a. 5A a. 4C
b. C7 b. E8
c. 9B5 c. 6D2
d. 1A6 d. 31B
7. Add the following binary numbers: 10. Express the decimal number 18 in each of the
following number codes:
a. 110 + 111 a. Binary
b. 101 + 011 b. Octal
c. Hexadecimal
c. 1100 + 1011
8. Subtract the following binary numbers:
a. 1101 − 101
b. 1001 − 110
c. 10111 − 10010
9. Convert each piece of binary information to the
appropriate hexadecimal code
a. 0001 1111
b. 0010 0101
c. 0100 1110
d. 0011 1001