0% found this document useful (0 votes)
4 views

Introduction to data structures

The document covers various data types, number systems, and their representations in digital computers, including binary, decimal, octal, and hexadecimal systems. It explains the concept of complements, specifically 1's and 2's complements for binary numbers, and discusses fixed-point and floating-point representations for numbers. Additionally, it highlights the arithmetic operations involving these representations, emphasizing the differences between fixed-point and floating-point formats.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Introduction to data structures

The document covers various data types, number systems, and their representations in digital computers, including binary, decimal, octal, and hexadecimal systems. It explains the concept of complements, specifically 1's and 2's complements for binary numbers, and discusses fixed-point and floating-point representations for numbers. Additionally, it highlights the arithmetic operations involving these representations, emphasizing the differences between fixed-point and floating-point formats.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 60

UNIT III

• 1.Data types
• 2.Complements
• 3.Fixed Point Representation
• 4.Floating Point Representation.
1.Data types:
●Registers contain either data or control information
●Control information is a bit or group of bits used to
specify the sequence of command signals needed for
data manipulation
●Data are numbers and other binary-coded information
that are operated on
●Possible data types in registers:
1. Numbers used in computations
2.Letters of the alphabet used in data processing
3. Other discrete symbols used for specific purposes
● All types of data, except binary numbers, are
represented in binary-coded form.
Number Systems :
1. radix:
A number system of base, or radix, r is a
system that uses distinct symbols for r digits
2.Decimal:
For example, 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 102 + 2 X 101 + 4 X
10° + 5 X 10-
3. Binary:
• 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 x25+Ox 24+1x 23+1x22+0x21+1x20=45
4.octal:
Besides the decimal and binary number
systems, the octal (radix 8) and hexadecimal
(radix 16) are important in digital computer
work
5. Hexadecimal:
• 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, 9, A, B, C, 0, 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,
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, 9, A, B, C, 0, 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,
Decimal Representation:
Alphanumeric Representation:
• 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 32 and 64 elements or
between 64 and 128 (if both uppercase and
lowercase letters are included).
Complements
• Complements are used in the digital computers
in order to simplify the subtraction operation
and for the logical manipulations.
• For each radix-r system (radix r represents
base of number system) there are two types of
complements.
Binary system complements:
•As the binary system has base r = 2.
•So the two types of complements for the binary
system are 2's complement and 1's complement.
1's complement:
•The 1's complement of a number is found by
changing all 1's to 0's and all 0's to 1's.
•This is called as taking complement or 1's
complement.
• Example of 1's Complement is as follows.
2's complement:

•The 2's complement of binary number is


obtained by adding 1 to the Least Significant
Bit (LSB) of 1's complement of the number.
•2's complement = 1's complement + 1
Example of 2's Complement is as follows.
• There are two types of complements for each
base r system:
1.r's complement and the
2.(r - l)'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.
(r - l )'s Complement(9'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, 10n represents a number that consists of a single 1
followed by n 10.
• 0' - 1 is a number represented by n 9's.
• For example, with n = 4 we have 104 = 10000 and 104 - 1= 9999.
• It follows that the 9' s complement of a decimal r number is
obtained by subtracting each digit from 9.
• For example, the 9's complement of 5467 10 is 999999 - 546710
= 453299 and the 9's complement of 12389 is 99999 - 12389 =
87610.
1's complement:
• For binary numbers, r = 2 and r - 1 = 1, so the 1's complement of N
is (2n - 1) - N.
• Again, 2' is represented by a binary number that consists of a 0
followed by n 10's.
• 2n - 1 is a binary number represented by n 1's.
• For example, with n = 4, we have 24 = (10000), and 24 - 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 0001 111 is 1110000.
(r's) Complement:(10's complement)
• The r's complement of an n-digit number N in base r
is defined as rn - N for N * D 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
76I0 + 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.
2's complement:
• Since 10n' is a number represented by a I followed by n 0's, then
10n' - 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 from 9.
• The 10's complement of 246700 is 753300 and is obtained by
leaving the two zeros unchanged, subtracting 7 from ID, 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 1101 100 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 other four most significant
bits.
Find 2’s complement of the following
i) 10010
ii) 111000
iii) 0101010
iv) 111111
Example 1: (1011000)2
This number has a base of 2, which means it is a binary
number. So, for the binary numbers, the value of r is 2,
and r-1 is 2-1=1. So, we can calculate the 1's and 2's
complement of the number.
1's complement of the number 1011000 is calculated as:
={(27)10-1}-(1011000)2
={(128)10-1}-(1011000)2
={(127)10}-(1011000)2
=11111112-10110002
=0100111
2's complement of the number 1011000 is
calculated as:

=(27 )10-(1011000)2
=(128)10-(1011000)2
=100000002-10110002
=01010002
Example 2: (155)10
This number has a base of 10, which means it is a decimal number.
So, for the decimal numbers, the value of r is 10, and r-1 is 10-1=9.
So, we can calculate the 10's and 9's complement of the number.
9's complement of the number 155 is calculated as:
={(103)10-1}-(155)10
=(1000-1)-155
=999-155
=(844)10
10's complement of the number 1011000 is calculated as:
=(103)10-(15510
=1000-155
=(845)10
Subtraction of Unsigned Numbers
• When subtraction is implemented with digital
hardware, this method is found to be less
efficient than the method that uses
complements.
• The subtraction of two n-digit unsigned
numbers M - N (N * 0) in base r can be done
as follows:
1. Add the minuend M to the r's complement of the
subtrahend N.
This performs M + (rn - N) = M - N + rn.
2. If M > N, the sum will produce an end carry r'
which is discarded, and what is left is the result M
- N.
3. If M < N, the sum does not produce an end carry
and is equal to rn - (N - M), which is the r's
complement of (N - M).
To obtain the answer in a familiar form, take the
r’ s complement of the sum and place a negative
sign in front.
3 Fixed-Point Representation
•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.
•The position of the binary point is needed to
represent fractions, integers, or
mixed integer-fraction numbers.
The representation of the binary point in a
register is complicated by the fact that it is
characterized by a position in the
register.
•There are two ways of specifying the
position of the binary point in a register:
by giving it a fixed position or by employing
a floating-point representation.
The two positions most widely used are
•(1) a binary point in the extreme left of the register to
make the stored number a fraction, and
•(2) a binary point in the extreme right of the register to
make the stored number an integer.
• In either case, the binary point is not actually present,
but its presence is assumed from the fact that the number
stored in the register is treated as a fraction or as an
integer.
•The floating-point representation uses a second register
to store a number that designates the position of the
decimal point in the first register.
•Floating-point representation is discussed further in the
next section.
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
Arithmetic Addition(2's complement
addition)Example
•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 1111 1001 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 .
Arithmetic Subtraction:
•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:
• The 9 in the leftmost position of the second number indicates that
the number is negative.
• 9760 is the 10's complement of 0240. The two numbers are added
and the end carry is discarded to obtain + 135.
• Of course, the decimal numbers inside the computer must be in
BCD, including the sign digits.
• The addition is done with BCD adders (see Fig. 10-18). The
subtraction of decimal numbers either unsigned or in the signed-10'
s complement system is the same as in the binary case.
• Take the 10' s complement of the subtrahend and add it to the
minuend.
• Many computers have special hardware to perform arithmetic
calculations directly with decimal numbers in BCD.
• The user of the computer can specify by programmed instructions
that the arithmetic operations be performed with decimal numbers
directly without having to convert them to binary.
• The main difference between fixed point and floating point is
that the fixed point has a specific number of digits reserved for
the integer part and fractional part while the floating point
does not have a specific number of digits reserved for the
integer part and fractional part.
• Fixed point and floating point are two ways of representing
numbers.
• There is a fixed number of digits for each portion even though
the number is VERY large or small.
• floating point, there is no specific number of digits to
represent integer section and fraction section.
• Floating point representation can cover a large range or
numbers when compared to fixed point.
4 Floating-Point Representation
Mantissa:
The floating-point representation of a number has two
parts.
The first part represents a signed, fixed-point number
called the mantissa.
Exponent:
• 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:
• 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+4.
• Floating-point is always interpreted to represent a number in the
following Form:
– m x r’ 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
conform with these two assumptions in order to provide the correct
computational results.
• A floating-point binary number is represented
in a similar manner except that it uses base 2
for the exponent.
• For example, the binary number + 1001 . 11 is
represented with a n 8-bit fraction and 6-bit
exponent a s follows:
Fraction:
• The fraction has a 0 in the leftmost position to
denote positive.
• The binary point of the fraction follows the
sign bit but is not shown in the register. The
exponent has the equivalent binary number +4.
• The floating-point number is equivalent to
• m x 2' = + (. 1001 110), x z+4
Normalization:
• A floating-point number is said to be
normalized if the most significant digit of the
mantissa is nonzero.
• For example, the decimal number 350 is
normalized but 00035 is not.
• Regardless of where the position of the radix
point is assumed to be in the mantissa, the
number is normalized only if its leftmost
• digit is nonzero. For example, the 8-bit binary
number 00011010 is not normal
• ized because of the three leading 0' s. The number can
be normalized by shifting it three positions to the left
and discarding the leading O's to obtain 11010000.
• The three shifts multiply the number by 23 = 8. To
keep the same value for the floating-point number, the
exponent must be subtracted by 3 .
• Normalized numbers provide the maximum possible
precision for the floating-point number.
• A zero cannot be normalized because it does not have
a nonzero digit.
• It is usually represented in floating-point by all O's in
the mantissa and exponent

You might also like