0% found this document useful (0 votes)
18 views11 pages

Chapter 2

Chapter 2 discusses data types in digital computers, including binary representation, number systems, and alphanumeric characters. It explains the significance of complements for subtraction and logical operations, as well as fixed-point representation for integers. The chapter also covers the conversion between different number systems such as binary, octal, and hexadecimal, and the methods for representing signed and unsigned integers.

Uploaded by

rexd1238
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views11 pages

Chapter 2

Chapter 2 discusses data types in digital computers, including binary representation, number systems, and alphanumeric characters. It explains the significance of complements for subtraction and logical operations, as well as fixed-point representation for integers. The chapter also covers the conversion between different number systems such as binary, octal, and hexadecimal, and the methods for representing signed and unsigned integers.

Uploaded by

rexd1238
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHAPTER – 2

➢ Data types
➢ Complements
➢ Fixed point representation
➢ Floating point representation
➢ Codes

2.1 Data types


Binary information in digital computers is stored in memory or processor registers.
Registers contain either data or control information. Control information is a bit or
a group of bits used to specify the sequence of command signals needed for
manipulation of the data in other registers. Data are numbers and other binary-
coded information that are operated on to achieve required computational results.
The data types found in the registers of digital computers may be classified as
being one of the following categories: (1) numbers used in arithmetic
computations, (2) letters of the alphabet used in data processing, and (3) other
discrete symbols used for specific purposes. All types of data, except binary
numbers, are represented in computer registers in binary-coded form. This is
because registers are made up of flip-flops and flip-flops are two-state devices that
can store only 1’s and 0’s. The binary number system is the most natural system to
use in a digital computer. But sometimes it is convenient to employ different
number systems, especially the decimal number system, since it is used by people
to perform arithmetic computations.
2.1.1 Number Systems
A number system of base, or radix, r is a system that uses distinct symbols for r
digits. Numbers are represented by a string of digit symbols. To determine the
quantity that the number represents, it is necessary to multiply each digit by an
integer power of r and then form the sum of all weighted digits. For ex, the decimal
number system in everyday use employs the radix 10 system. The 10 symbols are
0, 1, 2,3,4,5,6,7,8 and 9. The string of digits 724.5 is interpreted to represent the
quantity
7 x 10 + 2 x 10 + 4 x 10 + 5 x 10
that is, 7 hundreds, plus 2 tens, plus 4 units, plus 5 tenths. Every decimal number
can be similarly interpreted to find the quantity it represents.
The binary number system uses the radix 2. The two digit symbols used are 0 and
1. The string of digits 101101 is interpreted to represent the quantity
1 x 2 + 0 x 2 + 1 x 2 + 1 x 2 + 0 x 2 + 1 x 2 = 45
To distinguish between different radix numbers, the digits will be enclosed in
parentheses and the radix of the number inserted as a subscript. For example, to
show the equality between decimal and binary forty-five we will write (101101) =
(45).
Besides the decimal and binary number systems, the octal (radix 8) and
hexadecimal (radix 16) are important in digital computer work. The eight symbols
of the octal system are 0, 1, 2, 3, 4, 5, 6 and 7. The 16 symbols of the hexadecimal
system are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, A, B, C, D, E and F. The last six symbols
are, unfortunately, identical to the letters of the alphabet and can cause confusion at
times. However, this is the convention that has been adopted. When used to
represent hexadecimal digits, the symbols A, B, C, D, E, F correspond to the
decimal numbers 10, 11, 12, 13, 14, 15, respectively.
A number is radix r can be converted to the familiar decimal system by forming the
sum of the weighted digits. For ex, octal 736.4 is converted to decimal as follows:
(736.4) = 7 x 8 + 3 x 8 + 6 x 8 + 4 x 8
= 7 x 64 + 3 x 8 + 6 x 1 + 4/8 = (478.5)
The equivalent of decimal number of hexadecimal F3 is obtained from the
following calculation:
(F3) = F x 16 + 3 = 15 x 16 + 3 = (243)
2.1.2 Octal and Hexadecimal Numbers
The conversion from and to binary, octal and hexadecimal representation plays an
important part in digital computers. Since 2 = 8 and 2 = 16, each octal digit
corresponds to three binary digits and each hexadecimal digit corresponds to four
binary digits. The conversion from binary to octal is easily accomplished by
partitioning the binary number into groups of three bits each.

1010 1111 0110 0011


Table 1 below lists a few octal numbers and their representation in registers in
binary-coded form. Each octal digit is assigned a 3- bit code as specified by the
entries of the first eight digits in the table. Similarly, Table 2 lists a few
hexadecimal numbers and their representation in registers in binary-coded form.
Here the binary code is obtained by assigning to each hexadecimal digit the 4-bit
code listed in the first 16 entries of the table.
Table 1
Binary – Coded Octal Numbers
Octal Number Binary-Coded Octal Decimal Equivalent

0 000 0
1 001 1
2 010 2
3 011 3
4 100 4
5 101 5
6 110 6
7 111 7
10 001 000 8
11 001 001 9
12 001 010 10
24 010 100 20
62 110 010 50
143 001 100 011 99
370 011 111 000 248

Table 2
Binary – Coded Hexadecimal Numbers
Hexadecimal Binary-Coded Decimal Equivalent
Number Hexadecimal
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
A 1010 10
B 1011 11
C 1100 12
D 1101 13
E 1110 14
F 1111 15
14 0001 0100 20
32 0011 0010 50
63 0110 0011 99
F8 1111 1000 248

2.1.3 Alphanumeric Representation


Many applications of digital computers require the handling of data that consist not
only of numbers, but also of the letters of the alphabet and certain special
characters. An alphanumeric character set is a set of elements that includes the 10
decimal digits, the 26 letters of the alphabet and a number of special characters,
such as $, +, and =. Such a set contains between 64 and 128 (if both uppercase and
lowercase letters are included).

Character Binary Code Character Binary Code

A 100 0001 0 011 0000


B 100 0010 1 011 0001
C 100 0011 2 011 0010
D 100 0100 3 011 0011
E 100 0101 4 011 0100
F 100 0110 5 011 0101
G 100 0111 6 011 0110
H 100 1000 7 011 0111
I 100 1001 8 011 1001
J 100 1010 9
K 100 1011
L 100 1100
M 100 1101 space 010 0000
N 100 1110 . 010 1110
0 100 1111 ( 010 1000
P 101 0000 + 010 1011
Q 101 0001 $ 010 0100
R 101 0010 * 010 1010
S 101 0011 ) 010 1001
T 101 0100 - 010 1101
U 101 0101 / 010 1111
V 101 0110 , 010 1100
W 101 0111 = 011 1101
X 101 1000
Y 101 1001
Z 101 1010

2.2 Complements
Complements are used in digital computers for simplifying the subtraction
operation and for logical manipulation. There are two types of complements for
each base r system: the r’s complement and the (r-1)’s complement. When the
value of the base r is substituted in the name, the two types are referred to as the
2’s and 1’s complement for binary numbers and the 10’s and 9’s complement for
decimal numbers.
2.2.1 (r-1)’s Complement
Given a number N in base r having n digits, the (r-1)’s complement of N is defined
as (r-1) – N. For decimal numbers r = 10 and r – 1 = 9, so the 9’s complement of N
is (10 – 1) – N. Now, 10 represents a number that consists of a single 1 followed
by n 0’s. 10 – 1 is a number represented by n 9’s. For example, with n = 4 we have
10 = 10000 and 10 – 1 = 9999. It follows that 9’s complement of a decimal number
is obtained by subtracting each digit from 9. For example, the 9’s complement of
546700 is 999999 – 546700 = 453299 and 9’s complement of 12389 is 99999 –
12389 = 87610
For binary numbers, r = 2 and r-1 = 1, so the 1’s complement of N is (2 – 1) – N.
Again, 2 is represented by a binary number that consists of a 1 followed by n 0’s. 2
– 1 is a binary number represented by n 1’s. For example, with n = 4, we have 2 =
(10000) and 2 – 1 = (1111). Thus the 1’s complement of a binary number is
obtained by subtracting each digit from 1. However, the subtraction of a binary
digit from 1 causes the bit to change from 0 to 1 or from 1 to 0. Therefore, the 1’s
complement of a binary number is formed by changing 1’s into 0’s and 0’s into
1’s. For example, the 1’s complement of 1011001 is 0100110 and the 1’s
complement of 0001111 is 1110000.
The (r-1)’s complement of octal or hexadecimal numbers are obtained by
subtracting each digit from 7 or F (decimal 15) respectively.
2.2.2 (r’s) Complement
The r’s complement of an n- digit number N in base r is defined as r – N for N = 0
and 0 for N = 0. Comparing with the (r-1)’s complement, we note that the r’s
complement is obtained by adding 1 to the (r-1)’s complement since r – N = [(r –
1) – N] + 1. Thus the 10’s complement of the decimal 2389 is 7610 + 1 = 7611 and
is obtained by adding 1 to the 9’s complement value. The 2’s complement of
binary 101100 is 010011 + 1 = 010100 and is obtained by adding 1 to the 1’s
complement value.
Since 10 is a number represented by a 1 followed by n 0’s, then 10 – N, which is
the 10’s complement of N, can be formed also be leaving all least significant 0’s
unchanged, subtracting the first nonzero least significant digit from 10, and then
subtracting all higher significant digits form 9. The 10’s complement of 246700 is
753300 and is obtained by leaving the two zeroes unchanged, subtracting 7 from
10, and subtracting the other three digits from 9. Similarly, the 2’s complement can
be formed by leaving all least significant 0’s and the first 1 unchanged, and then
replacing 1’s by 0’s and 0’s by 1’s in all other higher significant bits. The 2’s
complement of 1101100 is 0010100 and is obtained by leaving the two low order
0’s and the first 1 unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in the
four most significant bits.
2.2.3 Subtraction of Unsigned Numbers
The direct method of subtraction taught in elementary schools uses the borrow
concept. In this method we borrow a 1 from a higher significant position when the
minuend digit is smaller than the corresponding subtrahend digit. This seems to be
easiest when people perform subtraction with paper and pencil. When subtraction
is implemented with digital hardware, this method is found to be less efficient than
the method that uses complements.
Consider for example, the subtraction 72532 – 13250 = 59282. The 10’s
complement of 13250 is 86750. Therefore:
M = 72532
10’s complement of N = + 86750
Sum = 159282
Discard end carry 10 = - 100000
Answer = 59282
Now consider an example with M < N. The subtraction 13250 – 72532 produces
negative 59282. Using the procedure with complements, we have
M = 13250
10’s complement of N =+ 27468
Sum = 40718
There is no end carry
Answer is negative 59282 = 10’s complement of 40718

2.2.4 Binary Addition

X INPUT Y SUM OUTPUT CARRY

0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

2.3 Fixed ~ Point Representation


Positive integers, including zero, can be represented an unsigned numbers.
However, to represent negative integers, we need a notation for negative values. In
ordinary arithmetic, a negative number is indicated by a minus sign and a positive
number by a plus sign. Because of hardware limitations, computers must represent
everything with 1’s and 0’s, including the sign of a number. As a consequence, it is
customary to represent the sign with a bit placed in the leftmost position of the
number. The convention is to make the sign bit equal to 0 for positive and to 1 for
negative. It is discussed further in the next section.
2.3.1 Integer Representation
When an integer binary number is positive, the sign is represented by 0 and the
magnitude by a positive binary number. When the number is negative, the sign is
represented by 1 but the rest of the number may be represented in one of three
possible ways:
1. Signed-magnitude representation
2. Signed – 1’s complement representation
3. Signed – 2’s complement representation
The signed-magnitude representation of a negative number consists of the
magnitude and a negative sign. In the other two representations, the negative
number is represented in either the 1’s or 2’s complement of its positive value. As
an example, consider the signed number 14 stored in 8- bit register. + 14 is
represented by a sign bit of 0 in the leftmost position followed by the binary
equivalent of 14: 00001110. Note that each of the eight bits of the register must
have a value and therefore 0’s must be inserted in the most significant positions
following the sign bit. Although there is only one way to represent +14, there are
three different ways to represent -14 with eight bits.
In signed-magnitude representation 1 0001110
In signed- 1’s complement representation 1 1110001
In signed- 2’s complement representation 1 1110010
The signed- magnitude representation of -14 is obtained from +14 by
complementing only the sign bit. The signed -1’s complement representation of -
14 is obtained by complementing all the bits of +14, including the sign bit. The
signed- 2’s complement representation is obtained by taking the 2’s complement of
the positive number, including its sign bit.
The signed-magnitude system is used in ordinary arithmetic but is awkward when
employed in computer arithmetic. Therefore, the signed-complement is normally
used. The 1’s complement imposes difficulties because it has two representations
of 0 (+ 0 and – 0). It is seldom used for arithmetic operations except in some older
computers. The 1’s complement is useful as a logical operation since the change of
1 to 0 or 0 to 1 is equivalent to a logical complement operation. The following
discussion of signed binary arithmetic deals exclusively with the signed- 2’s
complement representation of negative numbers.
2.3.2 Arithmetic Addition
The addition of two numbers in the signed- magnitude system follows the rules of
ordinary arithmetic. If the signs are the same, we add the two magnitudes and give
the sum the common sign. If the signs are different, we subtract the smaller
magnitude from the larger and give the result the sign of the larger magnitude. For
example, (+25) + (-37) = -(37 – 25) = - 12 and is done by subtracting the smaller
magnitude 25 from the larger magnitude 37 and using the sign of 37 for the sign of
the result. This is a process that requires the comparison of the signs and the
magnitudes and then performing either addition or subtraction. By contrast, the
rule for adding numbers in the signed- 2’s complement system does not require a
comparison or subtraction, only addition and complementation. The procedure is
very simple and can be stated as follows: Add the two numbers, including their
sign bits, and discard any carry out of the sign (leftmost) bit position. Numerical
examples for addition are shown below. Note that negative numbers must initially
be in 2’s complement and that if the sum obtained after addition is negative, it is in
2’s complement form.
+6 00000110 -6 11111010
+13 00001101 +13 00001101
---- -------------- ----- -------------
+19 00010011 +7 00000111

+6 00000110 -6 11111010
-13 11110011 -13 11110011
---- -------------- ----- --------------
-7 11111001 -19 11101101
In each of the four cases, the operation performed is always addition, including the
sign bits. Any carry out of the sign bit position is discarded, and negative results
are automatically in 2’s complement form.
The complement form of representing negative numbers is unfamiliar to people
used to the signed-magnitude system. To determine the value of a negative number
when in signed- 2’s complement, it is necessary to convert it to a positive number
to place it in a more familiar form. For example, the signed binary number
11111001 is negative because the leftmost bit is 1. Its 2’s complement is
00000111, which is the binary equivalent of +7. We therefore recognize the
original negative number to be equal to -7.
2.3.3 Arithmetic Subtraction
Subtraction of two signed binary numbers when negative numbers are in 2’s
complement form is very simple and can be stated as follows: Take the 2’s
complement of the subtrahend (including the sign bit) and add it to the minuend
(including the sign bit). A carry out of the sign bit position is discarded.
This procedure stems from the fact that a subtraction operation can be changed to
an addition operation if the sign of the subtrahend is changed. This is demonstrated
by the following relationship:
( A) - (+B) = ( A) + (- B)
( A) - (- B) = ( A) + (+B)
But changing a positive number to a negative number is easily done by taking its
2’s complement. The reverse is also true because the complement of a negative
number in complement form produces the equivalent positive number. Consider
the subtraction of (-6) - (-13) = +7. In binary with eight bits this is written as
11111010 – 11110011. The subtraction is changed to addition by taking the 2’s
complement of the subtrahend (-13) to give (+13). In binary this is 11111010 +
00001101 = 100000111. Removing the end carry, we obtain the correct answer
00000111 (+7).
It is worth noting that binary numbers in the signed-2’s complement system are
added and subtracted by the same basic addition and subtraction rules as unsigned
numbers. Therefore, computers need only one common hardware circuit to handle
both types of arithmetic. The user or programmer must interpret the results of such
addition or subtraction differently depending on whether it is assumed that the
numbers are signed or unsigned.
2.4 Floating~ Point Representation
The floating ~point representation of a number has two parts. The first part
represents a signed, fixed-point number called the mantissa. The second part
designates the position of the decimal (or binary) point and is called the exponent.
The fixed-point mantissa may be a fraction or an integer. For example, the decimal
number +6132.789 is represented in floating-point with a fraction and an exponent
as follows:
Fraction Exponent
+0.6132789 +04
The value of the exponent indicates that the actual position of the decimal point is
four positions to the right of the indicated decimal point in the fraction. This
representation is equivalent to the scientific notation +0.6132789 x 10.
Floating point is always interpreted to represent a number in the following form:
mxr
Only the mantissa m and the exponent e are physically represented in the register
(including their signs). The radix r and the radix-point position of the mantissa are
always assumed. The circuits that manipulate the floating point numbers in
registers confirm with these two assumptions in order to provide the correct
computational results.
2.5 Other binary Codes
Gray Code
Other Decimal Codes
Error Detection Codes

You might also like