You are on page 1of 30

DIGITAL LOGIC DESIGN

II Year II Sem , A.Y 2017-18, Reg: R16, Faculty Name: Mrs. K.Sowmya

UNIT I
Digital Systems and Binary Numbers
Syllabus:
Digital Systems, Binary Numbers, Binary Numbers, Octal and Hexadecimal Numbers, Complements of
Numbers, Complements of Numbers, Signed Binary Numbers, Arithmetic addition and subtraction

Introduction

INTRODUCTION of DIGITAL
Analog
An analog system has an infinite resolution (Continuous)
Like (old fashioned) radio dial
Work done is very little with analog
Eg: VGA, sound
Digital
A digital is a finite set of values (Discrete)
Like money
Cant get smaller than cents

Digital system is a system that manipulates discrete elements of information represented internally in
binary form

Analog system
The physical quantities or signals may vary continuously over a specified range.
Digital system
The physical quantities or signals can assume only discrete values.
Greater accuracy

Discrete information-processing systems


Manipulate discrete elements of information
For example, {1, 2, 3, } 10 and {A, B, C, } 26, playing cards - 54etc.
Discrete elements of information are represented in a digital system by physical quantities called signals.
Today it is a Digital age and an information age
Digital computers are for general purposes as well as for many scientific, industrial and commercial
applications
Digital systems eg:
o Telephone switching exchanges
o Digital camera
o Electronic calculators, PDA's
o Digital TV

Advantages of Digital System:


Generality
Flexibility
Variety of information processing tasks
Wide range of applications

Digital computer:

A digital computer stores data in terms of bits (0, 1) and proceeds in discrete steps from one state to the next.
In digital computers, even letters, words and whole texts are represented digitally.
Digital Logic is the basis of electronic systems, such as computers and cell phones. Digital Logic is rooted in
binary code; a series of 0s and 1s each having an opposite value. This system facilitates the design of
electronic circuits that convey information, including logic gates. Digital Logic facilitates computing,
robotics and other electronic applications.
Digital Logic designers build complex electronic components that use both electrical and computational
characteristics. These characteristics may involve power, current, logical function, protocol and user input.
Digital Logic Design is used to develop hardware, such as circuit boards and microchip processors. This
hardware processes user input, system protocol and other data in computers, navigational systems, cell
phones or other high-tech systems.

NUMBER SYSTEM

A number system is a way to represent numbers using a list of symbols.

A number system has a radix (also called base) whose value is equal to the total number of symbols allowed in
the number system.

Example, for the decimal number system: Radix, r = 10, Digits allowed = 0,1, 2, 3, 4, 5, 6, 7, 8, 9

In positional number systems, a number is represented by a string of digits, where each digit position has an associated
weight.

The value of a number is the weighted sum of the digits.

D ip1n di ri
The general representation of an unsigned number D with whole and fraction portions of the number in a number
system with radix r is :

(D)r =

Dp-1 Dp-2 .. D2 D1 D0 . D-1 D-2 D-n


The number above has p digits to the left of the radix point and n fraction digits to the right.
A digit in position i has as associated weight ri
The value of the number is the sum of the digits multiplied by the associated weight ri :

D ip1n di ri
Different Number System:

The most prominently studied number systems are:

Decimal

Binary

Octal

Hexadecimal

Decimal Number System:

Characteristics:

The decimal system is composed of 10 numerals or symbols.


These 10 symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Using these symbols as digits of a number, we can express
any quantity.
The decimal system is also called the base-10 system because it has 10 digits.
Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base)position 100, ..10p-1 from left of decimal point and 10-1 from right of
decimal point
Magnitude : Sum of Digit x Weight
Decimal Example

Eg : 24819.54

2 4 8 1 9 . 5 4

24819= 2x104 + 4 x103 + 8x102 + 1 x101 + 9x100+5x10-1+4x10-2

= 20000 + 4000 + 800 + 10 + 9 + 0.5 +0.04

= 24819.54

104 103 102 101 100 10-1 10-2

MSB LSB
Octal Number System:

Characteristics:

The octal system is composed of 8 numerals or symbols.


These 8 symbols are 0, 1, 2, 3, 4, 5, 6, and 7. Using these symbols as digits of a number, we can express any
quantity.
The octal system is also called the base-8 system because it has 8 symbols.
Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base)position 80, ..8p-1 from left of octal point and 8-1 from right of octal point
Magnitude : Sum of Digit x Weight
Octal Examples
3.1410
52.10
102410
640.0010
Eg : 716.5
7 1 6 . 5

716.5= 7x82 + 1 x81 + 6x80+5x8-1

= 7x64+ 7x8 + 6x1 + 0.625

= 510.625

84 83 82 81 80 8-1 8-2

MSB LSB

Hexadecimal Number System:

Characteristics:

The hexadecimal system is composed of 16 numerals or symbols.


These 16 symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. Using these symbols as digits of a
number, we can express any quantity.
Here A represents -10, B-11, C-12, D-13 , E-14 and F-15 respectively.
The hexadecimal system is also called the base-16 system because it has 16 symbols.
Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base) position 160..16p-1 from left of hexadecimal point and 16-1 from right
of hexadecimal point
Magnitude : Sum of Digit x Weight
Hexadecimal Example
Eg : (1E5.A)16

1 E 5 . A
1E5.A = 1 x 162 + E x161 + 5x160+Ax16-1+Ax16-2

= 1x256+ 14 x16 + 5 x 1 + 10 x 0.0625

= 325.625

164 163 162 161 160 16-1 16-2

.
MSB LSB

Binary Number System:

Characteristics:

The Binary system is composed of only 2 numerals or symbols.


These two symbols are 0 and 1. Using these symbols as digits of a number, we can express any quantity.
The binary system is also called the base-2 system because it has 2 symbols.
Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base) position 20..2p-1 from left of binary point and 2-1 from right of binary
point
Magnitude : Sum of Digit x Weight
Binary Example
Eg : (10110.101)2

1 0 1 1 0 . 1 0 1

10110.101= 1 x 24 +0 x 23 +1 x 22 + 1 x21 + 0x20 + 1x2-1+ 0x2-2 + 1x2-3

= 1x16+ 0 x8 + 1 x 4 + 1x2 + 0 x 1 + 1x0.5 + 0x0.25 + 1x0.125

= 16 + 0 + 4 + 2 + 0 + 0.5+ 0.25 + 0.125 =22.875

24 23 22 21 20 2-1 2-2

.
MSB LSB

Groups of bits

4 bits = Nibble
8 bits = Byte
1024 bytes= 210= 1Kilo Byte = 1KB
220= 210 x 210 = 210 Kilo Byte = 1Mega Bytes = 1MB
230= 210 x 220 = 210 Mega Byte = 1Giga Bytes = 1GB
240= 210 x 230 = 210 Giga Byte = 1Tera Bytes = 1TB
The Power of 2

40 30 20 12 11 10 9 8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
240 230 220 212 211 210 2 2 2 2 2 2 2 2 2 2
1T 1G 1M 4096 2048 1024 512 256 128 64 32 16 8 4 2 1

Problems (solutions in class notes, Assignment books, class tests)


State whether the following are TRUE/FALSE
(12)6
(90)5
(333)4
(16)6
(70)8
(F1)15
What is the value of the numbers of various numbering systems in decimal number system.
(4310) 5
(198)12
(735)8
(525)6
List the octal and hexadecimal numbers from 16 to 32.
Using A, B and C for the last three digits, list the numbers from 8 to 28 in base 13.
Express the following numbers in decimal:
(10110.0101) 2
(16.5)16
(26.24)8
(FA.FA)16
(1010.1010)2`
Few Solved Problems
(110000.0111)2 = ( ? )10

ANS: 48.4375

What is the exact number of bytes in a 16 Gbyte memory module?

ANS: 16 *230 BYTES


Conversions

Converting from one number system to another number system is called code conversion

Possible conversions are listed below

Number System Decimal Binary Octal Hexadecimal


Decimal - Yes Yes Yes
Binary Yes - Yes Yes
Octal Yes Yes - Yes
Hexadecimal Yes Yes Yes -

Process of converting a number in any radix r to decimal

The general representation of a number D with radix r, whole and fraction portions of the number is :

(D)r =

Dp-1 Dp-2 .. D2 D1 D0 . D-1 D-2 D-n

The number above has p digits to the left of the radix point and n fraction digits to the right.
A digit in position i has as associated weight ri
The value of the number in base 10 is the sum of the digits multiplied by the associated weight ri
:
D in di r
p1 i

10
Converting binary to decimal:

Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base) position 20..2p-1 from left of binary point and 2-1 from right of binary
point
Magnitude : Sum of Digit x Weight
Binary to decimal conversion Example
Eg : (10110.101)2

1 0 1 1 0 . 1 0 1

10110.101= 1 x 24 +0 x 23 +1 x 22 + 1 x21 + 0x20 + 1x2-1+ 0x2-2 + 1x2-3

= 1x16+ 0 x8 + 1 x 4 + 1x2 + 0 x 1 + 1x0.5 + 0x0.25 + 1x0.125

= 16 + 0 + 4 + 2 + 0 + 0.5+ 0.25 + 0.125 =22.875, Therefore (10110.101)2 = (22.875)10

Converting octal to decimal:

Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base)position 80, ..8p-1 from left of octal point and 8-1 from right of octal point
Magnitude : Sum of Digit x Weight
Octal to decimal conversion Example
Eg : 716.5
7 1 6 . 5

716.5= 7x82 + 1 x81 + 6x80+5x8-1


= 7x64+ 7x8 + 6x1 + 0.625 = 510.625 , (716.5)8= (510.625)10
Converting hexadecimal to decimal:

Position: digit position is with respective to the point (.) , left of point begins from 0 to p-1and right of point
begins from -1.
Weight: weight of the position is (base) position 160..16p-1 from left of hexadecimal point and 16-1 from right
of hexadecimal point Magnitude : Sum of Digit x Weight
Hexadecimal to decimal conversion Example
Eg : (1E5.A)16
1 E 5 . A

1E5.A = 1 x 162 + E x161 + 5x160+Ax16-1+Ax16-2


= 1x256+ 14 x16 + 5 x 1 + 10 x 0.0625
= 325.625 Therefore (1E5.A)16= (325.625)10
Process of converting decimal to number in any radix r

Conversion of decimal number to any radix number is done two steps.

In step 1, integer part is converted using division method.

Integer part conversion: Successive division of integer part i.e repeatedly divide the integer part of the decimal number
by r (base /radix of target number system) until the quotient is zero.

Collect all the remainders in reverse order to form the target radix number, i.e the first remainder is least significant
digit (LSD) and last remainder is most significant digit (MSD)

In step 2, fractional part is converted using multiplication method

Fractional part conversion: Repeatedly multiply the fractional part with radix until the fractional part raches zero or
until sufficient no. of digits in the fractional part of a new radix number.

Each multiplication results in integer part and fractional part. Collect all the integer parts in the same order of
occurrence to represent the target radix fractional part of the number.

Decimal to binary:
Decimal to Octal

Decimal to Hexadecimal

(3315.3)10 = ( ? )16
Problem:
Convert the following Decimal to Binary and octal
189
512
777
999
121
456

Relationship between Binary - Octal and Binary-hexadecimal

As demonstrated by the table below, there is a direct correspondence between the binary system and the octal system,
with three binary digits corresponding to one octal digit. Likewise, four binary digits translate directly into one
hexadecimal digit.

Decimal Binary Octal Hex

00 0000 00 0

01 0001 01 1

02 0010 02 2

03 0011 03 3

04 0100 04 4

05 0101 05 5

06 0110 06 6

07 0111 07 7

08 1000 10 8

09 1001 11 9

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

Conversions using Table

Conversion from and to binary, octal and hexadecimal plays an important part in digital computers

Sine 23 = 8 and 24 = 16, i.e each octal digit corresponds to 3 binary digits and each hexadecimal digit corresponds to
4 binary digits
Binary Octal Conversion

8 = 23
Each group of 3 bits represents an octal digit and works for both binary to octal conversion and octal to binary
conversion

Consider converting 101102 to base 8:


101102 = 0102 1102 = 28 68 = 268
Notice that the leftmost two bits are padded with a 0 on the left in order to create a full triplet.

Octal Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

Binary Hexadecimal Conversion

16 = 24
Each group of 4 bits represents an hexadecimal digit and works for both binary to hexadecimal conversion and
hexadecimal to binary conversion
Consider converting 101102 to base 16:
101102 = 00012 01102 = 116 616 = 1616
Notice that the leftmost two bits are padded with a 0 on the left in order to create a quartet triplet.
7 0111
Hex Binary
8 1000
0 0000
9 1001
1 0001
A 1010
2 0010
B 1011
3 0011
C 1100
4 0100
D 1101
5 0101
E 1110
6 0110
F 1111
Octal to Hexadecimal Conversion

Conversion from octal to hexadecimal is convenient if an intermediate binary conversion step is introduced.
First convert the octal number to binary and then convert binary number to hexadecimal number.

This works for both octal to hexadecimal and hexadecimal to octal

For hexadecimal to octal, first convert the hexadecimal number to binary and then convert binary number to octal
number.

Problems:
Convert the hexadecimal number 68BE to binary, and then convert it from binary to octal.
Convert the decimal number 431 to binary in two ways:
(a) Convert directly to binary;
(b) Convert first to hexadecimal and then from hexadecimal to binary.
Which method is faster?
Convert the following binary numbers to hexadecimal and 10 decimal: (a) 1.10010, (b) 110.010.
Explain why the decimal answer in (b) is 4 times that in (a).
What is the largest binary number that can be expressed with 14 bits?
What are the equivalent decimal and hexadecimal numbers?

Other Conversions

The conversion methods can be used to convert a number from any base to any other base, but it may not be very
intuitive to convert something like 513.03 in base 6 to base 7. As an aid in performing an unnatural conversion,
we can convert to the more familiar base 10 form as an intermediate step, and then continue the conversion from
base 10 to the target base. As a general rule, we use the polynomial method when converting into base 10, and we
use the remainder and multiplication methods when converting out of base 10.
CONVERSION SUMMARY TABLE

Number System Decimal Binary Octal Hexadecimal


Through
Repeated / of Integer part by 2 until Binary as
Through Binary as
quotient is zero and arrange intermediate
intermediate step.
remainders in reverse order and step. Convert
Convert to binary and
Decimal - multiplication of fractional part with 2 to binary and
group 4 bits are take
until fractional part is zero or up to group 3 bits
corresponding
required digits and arrange integer are take
Hexadecimal digit
parts of results in same order corresponding
octal digit
Group 3 bits
start from Group 4 bits start
LSB and pad from LSB and pad

i n di 2
p 1 i zero at MSB if zero at MSB if
Binary -
required are required are take
take corresponding
corresponding hexadecimal digit
octal digit
Through Binary as
Octal intermediate step.

i n d i 8
p 1 i Convert each octal digit to 3 bit binary Convert to binary and
-
bits and group all them together at end group 4 bits are take
corresponding
Hexadecimal digit
Through
Binary as
intermediate
Hexadecimal Convert each hexadecimal digit to 4 step. Convert

d 16
p 1 i bit binary bits and group all them to binary and -
in i together at end group 3 bits
are take
corresponding
octal digit

Complements
Complements are used to simplify the logical manipulations and subtraction operations.

There are two types of complements for each base-r system:


Diminished Radix Complement also called as (r-1)s Complement
Radix complement also called as rs Complement
For example:
In binary number system,
There exists 1s complement ((r-1)s complement) and 2s complement (rs complement)
In decimal number system,
There exists 9s complement ((r-1)s complement) and 10s complement (rs complement)

Diminished Radix Complement - (r-1)s Complement

Given a number N in base r having n digits in integer and m digits in fractional part, the (r1)s
complement of N is defined as:
(rn r-m) N
Example for 6-digit integer decimal numbers:
9s complement is (rn r-m) N = (106100)N = (1061)N =999999N
9s complement of 546700 is 999999546700 = 453299
Example:
Find 9s complement of the decimal number 1234.765

Sol:
N = 1234.765, r=10
n=4(integer part), m=3 (fractional part)

(10n10-m)N

(10410-3)N

10000-0.001-1234.765

=8765.234

Find 1s complement of 101100.101

Sol:
N=101100.101, r=2
n=6(integer part), m=3 (fractional part)
(2n2-m)N

(262-3)N

1000000-0.0001-101100.101

111111.111-101100.101

=010011.010

A simple technique to obtain a diminished complement is to subtract each digit from the highest digit of the
number system.
For decimal numbers subtract each digit from 9 to get the complement of the number.
For binary numbers subtract each digit from 1 to get the complement of the number, in other words, invert
1 to 0 and 0 to 1, because 1-1 is 0 and 1-0 is 1.

Find 9s complement of decimal number 1234.765

Sol:
Using the technique, each digit must be subtracted from 9.
9-1=8
9-2=7
9-3=6
9-4=5
9-7=2
9-6=3
9-5=4
Therefore the 9s complement is 8765.234
Find 1s complement of 101100.101
Sol:
Using the technique, each digit must be subtracted from 1 or invert simply 1to 0 and 0 to 1.
Therefore the complement of 101100.101 becomes 010011.010

Radix Complement - rs Complement

Given a number N in base r having n digits in integer part, the rs complement of N is defined as:
(rn ) N
Example for 6-digit integer decimal numbers:
10s complement is (rn ) N = (106)N = (106)N =1000000N
10s complement of 546700 is 1000000546700 = 453300
Example:
Find 10s complement of the decimal number 1234.765

Sol:
N = 1234.765, r=10
n=4(integer part)
(10n)N

(104)N

10000-1234.765

=8765.235

Find 2s complement of 101100.101

Sol:
N=101100.101, r=2
n=6(integer part),
(2n)N

(26)N

1000000-101100.101

=010011.011

A simple technique to obtain a radix complement is to subtract each digit from the highest digit of the
number system and add one to the total obtained result; i.e add one to (r-1)s complement, because radix
complement and diminished radix differ by one.
For decimal numbers subtract each digit from 9 to get the complement of the number and add one to the
total result.
For binary numbers scan from the least significant bit and copy till the first one encounters including the
first one, later invert 1 to 0 and 0 to 1.

Find 10s complement of decimal number 1234.765

Sol:
Using the technique, each digit must be subtracted from 9.

9-1=8
9-2=7
9-3=6
9-4=5
9-7=2
9-6=3
9-5=4
herefore the 9s complement is 8765.234
And add 1 to last digit therefore 10s complement becomes 8765.235

Find 2s complement of 101100.10100

Sol:
Using the technique, scan from LSB and copy till first one encounter then invert 1 to 0 and 0 to 1.
Therefore the 2s complement of 101100.101 becomes 010011.01100
Problems
Problem:

(a) Find the 16's complement of B2FA.


(b) Convert B2FA to binary.
(c) Find the 2's complement of the result in (b).
(d) Convert the answer in (c ) to hexadecimal and compare with the answer in (a).

Obtain the I' s and 2's complements of the following binary numbers:
(a) 10000000 (b) 00000000 (c) 11011010 (d) 0 11 10110 (e) 10000 101 (f) 1111 111 1.
Find the 9's and the 10's complement of the following decimal numbers:
(a) 52784630 (b) 63325600 (c) 25000.000 (d) 00000000.

Subtraction with rs complement

Consider two positive numbers M and N, both of base r. Subtraction of the two numbers i.e M N is as
follows:
1. Add (minuend) M to the rs complement of (subtrahend) N: M + (rn N)
2. Check end carry resulted from step 1
a. If an end carry occurs, discard the end carry and the result is then M N.
b. If an end carry doesnt occur, take rs complement of the result of step1 and place negative
sign before the result.
Technically
The subtraction of two ndigit unsigned numbers M - N in base r can be done as follows:
1. Add the minuend M to the rs complement of the subtrahend N. Mathematically, M + (r n - N) = M - N + r n.
2. If M N, the sum will produce an end carry r n, which can be discarded; what is left is the result M - N.
3. If MN, the sum does not produce an end carry and is equal to r n - (N - M), which is the rs complement of
(N - M). To obtain the answer in a familiar form, take the rs complement of the sum and place a negative
sign in front.

Example:
Using 10s complement, subtract 72532 - 3250.
M = 72532
10s complement of N = + 96750

Sum = 169282

Discard end carry 105 = -100000

Answer = 69282

Note that M has five digits and N has only four digits. Both numbers must have the same number of digits,
so we write N as 03250. Taking the 10s complement of N produces a 9 in the most significant position. The
occurrence of the end carry signifies that M N and that the result is therefore positive.

Using 10s complement, subtract 3250 - 72532.


M = 03250
10s complement of N = + 27468

Sum = 30718

There is no end carry. Therefore, the answer is -(10s complement of 30718) = -69282. Note that since 3250
< 72532, the result is negative. When subtracting with complements, we recognize the negative answer from
the absence of the end carry and the complemented result.
Problem
Subtract using the 10s complement (a) 4,637 - 2,579 (b) 125 - 1,800 (c) 2,043 - 4,361 (d) 1,631 - 745

Subtraction with complements is done with binary numbers in a similar manner, using the procedure
outlined previously.
Example 1.7
Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction
(a) X Y by using 2's complement.

(b) Y X, by using 2's complement.

There is no end carry. Therefore, the answer is Y X = (2's complement of 1101111) = 0010001

Problems:
Subtract using the 2s complement
(a) 10011 - 10010 (b) 100010 100110 (c) 1001 - 110101 (d) 101000 - 10101

Subtraction with (r-1)s complement

Consider two positive numbers M and N, both of base r. Subtraction of the two numbers i.e M N is as
follows:
1. Add (minuend) M to the (r-1)s complement of (subtrahend) N: M + ((rn-1) N)
2. Check end carry resulted from step 1
a. If an end carry occurs, add the end carry to the result and the result is then M N.
b. If an end carry doesnt occur, take (r-1)s complement of the result of step1 and place
negative sign before the result.

Technically

The subtraction of two ndigit unsigned numbers M - N in base r can be done as follows:

1. Add the minuend M to the rs complement of the subtrahend N. Mathematically, M + ((r n-1) - N) = M - N -
1 + r n.
2. If M N, the sum will produce an end carry (r n-1), which one less than rn s complement of N; what is left
1 less than is the result M N, before the carry must be added to result.
3. If MN, the sum does not produce an end carry and is equal to r n-1 - (N - M), which is the (r-1)s
complement of (N - M). To obtain the answer in a familiar form, take the (r-1)s complement of the sum
and place a negative sign in front.
Example:
Using 9s complement, subtract 72532 - 3250.
M = 72532
9s complement of N = + 96749

Sum = 169281
69281
add end carry 1 = 1

Answer = 69282

Note that M has five digits and N has only four digits. Both numbers must have the same number of digits,
so we write N as 03250. Taking the 9s complement of N produces a 9 in the most significant position. The
occurrence of the end carry signifies that M N and that the result is therefore positive.

Using 9s complement, subtract 3250 - 72532.

M = 03250
9s complement of N = + 27467

Sum = 30717

There is no end carry. Therefore, the answer is -(9s complement of 30717) = -69282. Note that since 3250
< 72532, the result is negative. When subtracting with complements, we recognize the negative answer from
the absence of the end carry and the complemented result.

Subtraction with complements is done with binary numbers in a similar manner, using the procedure
outlined previously.
Example 1.7
Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction
(a) X Y by using 1's complement.

(b) Y X, by using 1's complement.

There is no end carry. Therefore, the answer is Y X = (1's complement of 1101110) = 0010001
Signed Binary Numbers
Signed numbers are either positive or negative. The positive numbers are represented in only one way but the negative
numbers are represented in three ways. Signed numbers representation is divided into two parts, MSB is for sign of
the number and remaining are represent the number.
Three ways of representing Signed negative Binary Numbers
Signedmagnitude representation
signed1scomplement representation
signed2scomplement representation

The MSB bit stands for sign


1: negative
0: positive

Signedmagnitude representation: In signedmagnitude representation, MSB stands for sign i.e 1 is for
negative and 0 for positive and remaining digits are directly the magnitude of the number.
4 bit format 8 bit format

b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0

Sign Magnitude Sign Magnitude

For example:

-6 in Signedmagnitude representation -9 in signed magnitude representation


b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0
1 1 1 0 1 0 0 0 1 0 0 1

Sign Magnitude Sign Magnitude

Signed1scomplement representation: In signed1scomplement representation, MSB stands for sign i.e 1


is for negative and 0 for positive and remaining digits are in 1scomplement of the number.

4 bit format 8 bit format

b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0

Sign ones complement Sign ones complement

For example:
-6 in Signed ones complement representation -9 in signed ones complement representation
b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0
1 0 0 1 1 1 1 1 0 1 1 0

Sign ones complement Sign ones complement


Signed2scomplement representation: In signed2scomplement representation, MSB stands for sign i.e 1
is for negative and 0 for positive and remaining digits are the 2scomplement of the number.
4 bit format 8 bit format

b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0

Sign twos complement Sign twos complement

For example:
-6 in Signed twos complement representation -9 in signed twos complement representation
b3 b2 b1 b0 b7 b6 b5 b4 b3 b2 b1 b0
1 0 1 0 1 1 1 1 0 1 1 1

Sign twos complement Sign twos complement

Examples:
Although there is only one way to represent +9, there are three different ways to represent -9 with eight bits:

Signedmagnitude representation: 10001001


signed1scomplement representation: 11110110
signed2scomplement representation: 11110111

Table 1.3 lists all possible four bit signed binary numbers for equivalent decimal numbers in the three
representations.
Note:
The positive numbers in all three representations are identical and have 0 in the leftmost position.
The signed 2s complement system has only one representation for 0, which is always positive.
The other two systems have either a positive 0 or a negative 0, something not encountered in
ordinary arithmetic.
All negative numbers have a 1 in the leftmost bit position; that is the way we distinguish them from
the positive numbers.
With four bits, in the signed magnitude and in the 1s complement representations, there are eight
positive numbers and eight negative numbers, including two zeros.
In the 2s complement representation, there are eight positive numbers, including one zero and eight
negative numbers.

For Arithmetic:

Disadvantage of using signed magnitude for arithmetic:


The signed magnitude system is used in ordinary arithmetic, but is awkward when employed in computer
arithmetic because of the separate handling of the sign and the magnitude.

Disadvantage of using signed 1s complement for arithmetic:


The 1s complement imposes difficulties due to representation of zero is two different ways and is seldom
used for arithmetic operations. It is useful as a logical operation, since the change of 1 to 0 or 0 to 1.

Advantage of using signed 2s complement for arithmetic:


Signed binary arithmetic deals exclusively with the signed 2s complement because of its representing zero
in only one way and sign is not separated in operation

Signed Binary number Range of decimal numbers represented For 4 bits the possible range of
Representation (N is no. of bits) representation is
Signed Magnitude
-(2(N-1) -1) to +(2(N-1) -1) -7 to +7
Representation
signed1scomplement
-(2(N-1) -1) to +(2(N-1) -1) -7 to +7
representation
signed2scomplement
2(N-1) to +(2(N-1) -1) -8 to +7
representation

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 difference the sign if the larger magnitude.
The addition of two signed binary numbers with negative numbers represented in signed-2's-
complement form is obtained from the addition of the two numbers, including their sign bits.
A carry out of the sign-bit position is discarded.
Example:
Arithmetic Subtraction
In 2s-complement form, take the 2s complement of the subtrahend (including the sign bit) and add it to the
minuend (including sign bit). A carry out of sign-bit position is discarded.

For example:

( 6) ( 13) (11111010 11110011)


(11111010 + 00001101)
00000111 (+ 7)
But changing a positive number to a negative number is easily done by taking the 2s complement of the
positive number; this accommodates only one process for subtraction and addition. Computers need only
one common hardware circuit to handle both types of arithmetic.
This consideration has resulted in the signed 2s complement system being used in virtually all arithmetic
units of computer systems.

Problems:
The following decimal numbers are shown in signmagnitude form: +9,286 and +801. Convert them to
signed-10scomplement form and perform the following operations (note that the sum is +10,627 and
requires five digits and a sign).
(a) (+9,286) + (+801) (b) (+9,286) + (-801) (c) (-9,286) + (+801) (d) (-9,286) + (-801)

Convert decimal +49 and +29 to binary, using the signed2scomplement representation and enough digits
to accommodate the numbers. Then perform the binary equivalent of
(+29) + (-49), (-29) + (+49), and (-29) + (-49). Convert the answers back to decimal and verify that they are
correct.

If the numbers (+9,742) 10 and (+641) 10 are in signed magnitude format, their sum is (+10,383)10 and
requires five digits and a sign. Convert the numbers to signed-10scomplement form and find the following
sums:
(a) (+9,742) + (+641) (b) (+9,742) + (-641) (c) (-9,742) + (+641) (d) (-9,742) + (-641)

Other Binary Codes

The digital data is represented, stored, transmitted and processed as group of binary digits (bits), called
as binary code.

A binary code may represent numbers, letters, words, as well as special characteristics and control
functions.

An n-bit binary code is a group of n bits that assumes up to 2n distinct combinations of 1s and 0s, with
each combination representing one element of the set that is being coded.

For example, using 2 bits, we can have 4 combination codes (00, 01, 10, 11). Using n bit binary code, we
have 2n codes ( 0 to 2n-1).
Although the minimum number of bits required to code 2n distinct quantities is n, there is no maximum
number of bits that may be used for a binary code.
There are various binary codes used for different purposes.
Classification of binary codes: (\Properties of binary codes)

Error Detecting &


Weighted Non-weighted Self- Sequential Alpha-numeric
Correcting codes
complementing

8421 Excess-3 Hamming


Parity

ASCII EBCDIC

Excess-3 Gray

Excess-3 2421 5211

Binary BCD (Binary Coded Decimal)

8421 2421 5211 84-2-1

Weighted code: In a weighted code, each digit is assigned a specific weight according to its position.
There are several systems of weighted codes, like binary and BCD.

BCD codes:
Each decimal digit is represented using a 4-bit binary code.
A number with k decimal digits will require 4xk bits in BCD.
Decimal 396 is represented in BCD with 12bits as 0011 1001 0110, with each group of 4 bits
representing one decimal.
BCD can be represented using various weights like 8421,2421,84-2-1,5211,6311 etc.
Disadvantage: BCD number needs more bits than its equivalent binary value.
Advantage: Easy for conversions of decimal numbers to binary coded decimals and back to
decimal system
8421 :
Standard BCD code, often referred as BCD.
A decimal number in 8421 BCD is the same as its equivalent binary number only when the
number is between 0 and 9.
The binary combinations 1010 through 1111 are not used and have no meaning in this code.
Decimal 396 is represented in BCD with 12bits as 0011 1001 0110, with each group of 4 bits
representing one decimal
Disadvantage: BCD number needs more bits than its equivalent binary value.
Advantage: Easy for conversions of decimal numbers to binary coded decimals and back to
decimal system.
It is important to realize that BCD numbers are decimal numbers and not binary numbers,
although they use bits in their representation.
Example:
Consider decimal 185 and its corresponding value in BCD and binary:

Non-Weighted code: In a non-weighted code, digits are assigned codes irrespective of the weights.
They are few such codes like gray code and excess-3 code

Excess-3 code:
Excess-3 is a non-weighted code in which each coded combination is obtained from the
corresponding binary value plus 3; i.e add 0011.
Excess-3 self- complementing code, sequential and non-weighted.
Eg: 6 in BCD is 0110 and in excess-3 it is 1001
It is not limited to 0-9

Gray code:

The output data of many physical systems are quantities that are continuous and need to be sent to
digital systems as input. These data must be converted into digital form before they are applied
to a digital system. Gary code is convenient to use.
The advantage of the Gary code over the straight binary number sequence is that only
one bit in the code group changes in going from one number to the next. For example, in
going from 7 to 8, the Gary code changes from 0100 to 1100. Only the first bit changes, from
0 to 1; the other three bits remain the same. By contrast, with binary numbers the change
from 7 to 8 will be from 0111 to 1000, which causes all four bits to change values.
It is not limited to 0-9
Any two consequent decimal numbers differ by only one bit in gray code
The Gary code is used in applications in which the normal sequence of binary numbers
generated by the hardware that may produce an error or ambiguity during the transition from
one number to the next.
The Gary code eliminates erroneous transmission, since only one bit changes its value during
any transition between two numbers.
A typical application of the Gary code is the representation of analog data by a continuous
change in the angular position of a shaft.
GRAY CODE IS ALSO CALLED AS REFLECTION CODE OR MIRROR CODE,
because it can generated by reflection.
It is a cyclic code
It is not useful for arithmetic operations
Main advantages of gray code are:
The advantage is that only bit in the code group changes in going from one number to
the next.
Error detection.
Representation of analog data.
Low power design.

Conversion from binary code to gray code

1. Take the MSB as it, MSB of gray code is


same as MSB of binary.
2. Start from MSB and perform X-OR with
adjacent and take result as target adjacent
gray bit of MSB, continue till LSB.

Steps to convert binary code to gray code:


Conversion from gray code to binary code

Steps to convert gray code to binary code:

1. Take the MSB as it, MSB of binary code is same as MSB of gray.
2. Start from MSB and perform X-OR with adjacent and take result as target adjacent binary bit of
MSB, continue till LSB.

Self-complementing code: is a binary code in which the complement is formed by taking the 1's
complement
Examples : Excess-3 and 2421
9 in Excess-3 is 1100 and its complement is 0 i.e 0011
9 in 2421 is 1111 and its complement is 0 i.e 0000
6 in Excess-3 is 1001 and its complement is 3 i.e 0110
6 in 2421 is 1100 or 0110 and its complement is 3 i.e for 0011 or 1001 respectively
6 in 8421 is 0110 and its complement is 3 i.e 0011 and is not self-complementing code

Sequential codes: Successive codes differ by decimal 1. Examples: 8421,excess-3

Code\Property Weight Self-Complementing Purpose

BCD(8421) Weighted Not -Self-Complementing Easy Conversion from Decimal to Binary

2421 Weighted Self-Complementing Easy complement of Decimal

Excess-3 Non-Weighted Self-Complementing Easy Complement

Gary Non-Weighted Not -Self-Complementing Useful for Analog compliance


Problems:

Represent the unsigned decimal numbers 791 and 658 in BCD


Formulate a weighted binary code for the decimal digits, using the following weights:
(a) * 6, 3, 1, 1 (b) 6, 4, 2, 1
Represent the decimal number 6,248 in (a) BCD, (b) excess3 (c) 2421 (d) 6311 code.
Find the 9s complement of decimal 6,248 and express it in 2421 code. Show that the result is the 1s
complement of the answer to 6248 in 2421 code.
Assign binary code in some orderly manner to the 52 playing cards. Use the minimum number of bits.

Alphanumeric Codes:

These codes are used to represent different alphabets, numbers, symbols and various instructions.

Few alphanumeric codes: ASCII(American Standard Code for Information Interchange) ,

EBCDIC(Extended BCD Interchange Code)

American Standard Code for Information Interchange (Refer to Table)


It uses 7-bits to represent:
94 printable characters.
34 Non-printable(functional) characters.
94-26(a-z)-26(A-Z)-10(0-9)=>94-62=32 Special printable characters(other than alphabets
and numbers)
Non-printing characters are used for text format (e.g. BS = Backspace, CR = carriage return), record
marking and flow control.
ASCII has some interesting properties:
Digits 0 to 9 span Hexadecimal values 3016 to 3916
Upper case A-Z span 4116 to 5A16
Lower case a-z span 6116 to 7A16
Lower to upper case translation (and vice versa) occurs by flipping bit 6.
ASCII is a sevenbit code, but most computers manipulate an eightbit quantity as a single unit called
a byte. Therefore, ASCII characters most often are stored one per byte. The extra bit is sometimes
used for other purposes, depending on the application.
For example, some printers use eightbit ASCII characters with the most significant bit set to 0.
An additional 128 eightbit characters with the most significant bit set to 1 are used for other
symbols, such as the Greek alphabet or italic type font.
Problem:
Write the expression G. Boole in ASCII, using an eightbit code. Include the period and the space.
Treat the leftmost bit of each character as a parity bit. Each eightbit code should have odd parity.
(George Boole was a 19thcentury mathematician. Boolean algebra, introduced in the next chapter, bears
his name.)
Decode the following ASCII code:
1010011 1110100 1100101 1110110 1100101 0100000 1001010 1101111 1100010 1110011
How many printing characters are there in ASCII? How many of them are special characters?
What bit must be complemented to change an ASCII letter from capital to lowercase and vice versa?
Error-Detecting & Error-Correcting Codes:
During transmission of data, error in data might occur. To detect and correct such errors, we have
error detection and correction codes
Few such codes are parity codes and hamming codes.
Parity Code: A parity bit is an extra bit included with a message to make the total number of 1's
either even or odd. So, it is two types odd parity, even parity.
Redundancy (e.g. extra information), in the form of extra bits, can be incorporated into binary code
words to detect and correct errors.
A simple form of redundancy is parity, an extra bit appended onto the code word to make the number
of 1s odd for odd parity and even for even parity.
Parity can detect all single-bit errors and sometimes multiple-bit errors.
A code word has even parity if the number of 1s in the code word is even.
A code word has odd parity if the number of 1s in the code word is odd.
Example:
Message A: 10001001 1(even parity)
Message B: 10001001 0(odd parity)
Problems:
List the ASCII code for the 10 decimal digits with an even parity bit in the leftmost position.
Convert decimal 6,514 to both BCD and ASCII codes. For ASCII, an even parity bit is to be
appended at the left.

To detect errors in data communication and processing, an eighth bit is sometimes added to the ASCII
character (before MSB) to indicate its parity.

Problems:

The following is a string of ASCII characters whose bit patterns have been converted into hexadecimal for
compactness: 73 F4 E5 76 E5 4A EF 62 73. Of the eight bits in each pair of digits, the leftmost is a parity
bit. The remaining bits are the ASCII code.
Convert the string to bit form and decode the ASCII.
Determine the parity used: odd or even?

R13 Previous External Questions of UNIT I

II B. Tech I Semester Regular Examinations, Jan 2015

Part A
1. a) What are the characteristics of 2s complement numbers? (3M)
2. a) How are negative numbers represented? (2M)
3. a) What do you mean by end around carry? When does it come into picture? (2M)
4. a) Why is the binary number system used in digital systems? (2M)
Part B
1.a) The solution to the quadratic equation x2 11x + 22 = 0 is x = 3 and x = 6. What is the base
of numbers.
b) Using 10s complement, subtract
i) 7253210-325010 ii) 325010-7253210. What do you infer from the results. (8M+8M)
2. a) What is the advantage of 1s and 2s complement in computers. Represent +45 and -45 in
sign-magnitude, sign-1s complement and sign-2s complement representation.
b) Explain about Weighted and non-weighted codes (8M+8M)
3. a) The binary numbers listed have a sign bit in the left most position and, if negative numbers
are in 2s complement form. Perform the arithmetic operations indicated and verify the
answers.
i) 101011 + 111000 ii) 001110 + 110010 iii) 111001 001010 iv) 101011 100110
b) Explain about Weighted and non-weighted codes (8M+8M)
4. a) Explain how 1's complement and 2's complement of a binary number is obtained? Illustrate
by an example.
b) What is gray code? What are the rules to construct gray code? Develop the 4 bit gray code
for the decimal 0 to 15. (8M+8M)
II B. Tech I Semester Supplementary Examinations, June 2015
PART A
a) (25.75)10 to binary number 4M
a) Convert the decimal number 46 to binary number system also explain the steps of conversion 4M
a) Decimal number 86 to octal number system also explain the steps of conversion (4M)
a) Convert 6ABC.2A to decimal number system 4M
PART B
1. a) Perform the following arithmetic operation using ls complement method : i) Add (-19)10 and (29)
10 ii) Add (21)10 and (37)10 8M
b) The Hamming code 010110110 is received at the receiving end. Correct the received data if there
is any error. 8M
2. a) Perform the following using BCD arithmetic. i)126310 + 968710 ii)767210 + 337810 8M
b) Perform the following subtraction: i) (11010)2 (10000)2 using 1s complement ii) (1000100)2 -
(1010100)2 using 2s complement 8M
3. a) Briefly explain error detecting and error correcting codes with examples. (8M)
b) Convert the following to Decimal and then to Hexadecimal. i) 12678 ii) 110111012 iii) 78610 (8M)
4. a) Using 2s complement perform the following: i) (42)10 - (68)10 ii) (78)16 (56)16 8M
b) Perform each of the following decimal subtraction in excess-3 code i) 29 14 ii) 205 196
iii) 471 352 8M
II B. Tech I Semester Regular/Supplementary Examinations, Dec 2015.
Part A
Convert (615.25)8 to its hexadecimal equivalent (set1 4 M)
Convert (12.125)10 into binary (Set 2 3M)
Perform (28)10 (15)10 using 6 bit 2s complement representation. (Set3-4M)
Perform subtraction (1110)2- (1010)2 using 2 complement method. (3M)
Part B
SET1
a)Find the difference of (3250-72546)10 by using 10s complement. (8M)
b) Perform the following: i) 11010 1101
ii) 101011 100110 (using 2s complement) (8M)
SET2
a) Add and subtract in binary.
i) 1111 and 1010 ii) 110110 and 11101
iii) 100100 and 10110 iv) 1101001 and 11011
(8M)
b) Explain any two binary weighted codes with example (8M)
SET 3
a) Convert the decimal numbers 250.5, 12.0625, 673.23 to binary, base 8 and base 16. [9M]
b) Explain any two non-weighted codes with example [7M]
a) Subtract the following numbers using 9s complement and 10s complement.
i) 5250 321
ii) 753 864
iii) 3570 2100
iv) 20 100 (8M)
b) Convert the following:
i) (163.789)10 = ( )8
ii) (101101110001.00101)2 = ( )8
iii) (292)16 = ( )2 (8M)
II B. Tech I Semester Supplementary Examinations, June 2016

Pending:Regular Dec 2016, Supply May 2017

You might also like