Digital Design Digital Sytems Number Systems

NEELESHATOM1 22 views 116 slides May 03, 2024
Slide 1
Slide 1 of 116
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99
Slide 100
100
Slide 101
101
Slide 102
102
Slide 103
103
Slide 104
104
Slide 105
105
Slide 106
106
Slide 107
107
Slide 108
108
Slide 109
109
Slide 110
110
Slide 111
111
Slide 112
112
Slide 113
113
Slide 114
114
Slide 115
115
Slide 116
116

About This Presentation

Digital design


Slide Content

19Z204-Digital Design
Dr.S.Sivaranjani,AP-CSE

Course Topics(Unit –I)
•IntroductiontoDigitalSystems
•Numbersystems
•Number-Baseconversion
•ComplementsofNumbers(DiminishedRadix
complement,RadixComplement)
•SignedBinaryNumbers
•ArithmeticoperationwiththeBinaryNumbers
•BinaryCodes(BCD,8421code,Graycode,ASCII)
Dr.S.Sivaranjani,AP-CSE

•DigitalSystemsarepartofyourdailyactivities.
•EverythinginDigital(HighResolutionDisplay):Camera,
Laptop,Mobilephones,Tab-weareusingDigitalElectronics
Dr.S.Sivaranjani,AP-CSE
Data processing
Data transmission
Device control
Digital
Systems
Made or build using
Introduction to Digital Systems

•DigitalDeviceshaveGUI[GraphicalUser
Interface]
•Enablethedevicestoexecutecommandsthat
appeartotheusertobesimplebutwhich
involvespreciseexecutionofasequenceof
complexinternalinstructions
•DigitalSystemsarefast,accurateand
consumelesspower.
Dr.S.Sivaranjani,AP-CSE

Digital Systems
•Stemmingfromword“Digit”[means0,1,2,3…]
•Usedigitalsignalsorinformationtooperate
•DigitalSignals:arediscretesignalsthat
representinformationintheformofbinary
digits(bits)whichcantakeonlyoneoftwo
values(0&1)
Dr.S.Sivaranjani,AP-CSE

Processed
Stored
Transmitted
Dr.S.Sivaranjani,AP-CSE
Digital
Signals
Can be
Digital
Devices
Using
Smartphones,
Computers,Tablets&
other Electronic devices

Components of Digital Systems
•These components work together to process, store and transmit digital
information
Dr.S.Sivaranjani,AP-CSE
Digital
System
I/P Devices
[used to provide input to
the system in the form of
digital signals, such as
switches, sensors, and
keyboards]
Output Devices
[used to display or transmit
the processed information,
such as monitors, printers,
and speakers]
Processors
[The processing devices
perform the required logic
and arithmetic operations
on the input signals, such
as microprocessors and
microcontrollers. ]
Memory
Storage Devices
[storagedevicesareused
tostoredataand
instructions,suchas
memorychipsandhard
drives]

What is Digital System?
Dr.S.Sivaranjani,AP-CSE
Digital System
Digital Input Digital output
Discrete numbers
Process Digital information.
Processing will happen using Digital Logic

•Adigitalsystemisasystemthatprocesses
informationinadigitalform.
•Itconsistsofelectronicdevicesthat
manipulatedigitalsignals,suchasbinary
code,usingasetoflogicgatesandalgorithms.
•Thesedevicesincludemicroprocessors,
microcontrollers,digitalsignalprocessors,and
otherdigitalintegratedcircuits.
Dr.S.Sivaranjani,AP-CSE

Applications of digital system
Digitalsystemshaveawiderangeofapplicationsinvariousfields,including:
Communicationsystems:
•Digitalsystemsareusedincommunicationsystems,suchascellular
phones,satellites,andtheinternet.
•Theyenablereliabletransmissionandreceptionofdataandvoicesignals
overlongdistances.
Controlsystems:
•Digitalsystemsareusedincontrolsystems,suchasrobotics,process
control,andautomotivecontrolsystems.
•Theyallowforprecisecontrolofdevicesandprocesses,ensuringoptimal
performance.
Digitalsignalprocessing:
•Digitalsystemsareusedindigitalsignalprocessingapplications,suchas
audioandvideoprocessing,imageandspeechrecognition,andradarand
sonarsystems.
Dr.S.Sivaranjani,AP-CSE

Medical devices:
•Digitalsystemsareusedinmedicaldevices,such
aspacemakers,MRImachines,anddigitalX-ray
machines.
•Theyenableaccurateandreliablediagnosticand
treatmentprocedures.
Consumerelectronics:
•Digitalsystemsareusedinconsumerelectronics,
suchassmartphones,tablets,laptops,andsmart
TVs.
•Theyprovideawiderangeoffunctionsand
capabilities,suchasmultimediaplayback,
internetaccess,andgaming.
Dr.S.Sivaranjani,AP-CSE

Industrial automation:
•Digitalsystemsareusedinindustrialautomation
systems,suchasmanufacturingplants,assembly
lines,andlogisticssystems.
•Theyenableefficientandautomatedcontrolof
productionandlogisticsprocesses.
Defenseandaerospace:
•Digitalsystemsareusedindefenseand
aerospaceapplications,suchasmilitary
communicationsystems,guidanceandcontrol
systemsforaircraftandmissiles,andsatellite
communicationandnavigationsystems.
Dr.S.Sivaranjani,AP-CSE

Number System
Dr.S.Sivaranjani,AP-CSE

General Representation
•A number is represented as
a
5a
4a
3a
2a
1a
0.a
-1a
-2a
-3a
-4
•. -radix point
•a
j–coefficients(symbols used in a number representation)
•j –place value
•Example:
–Decimal number: 567.28
Dr.S.Sivaranjani,AP-CSE

Radix or Base
•Theradixofanumbersystemisalsoknownas
itsbaseoritsnumericalbase.
•Itreferstothenumberofuniquedigitsor
symbolsusedinthesystemtorepresent
numbers.
•Forexample,thedecimalsystemthatweuse
ineverydaylifehasaradixof10becauseit
uses10digits(0-9)torepresentnumbers.
Dr.S.Sivaranjani,AP-CSE

•Theradixofanumbersystemisanintegergreaterthan
1.
•Thevalueoftheradixdeterminestherangeofvalues
thatcanberepresentedusingthesystem,aswellas
thewayinwhichnumbersarewrittenand
manipulated.
•Forexample,inabinarysystemwitharadixof2,there
areonlytwopossibledigits(0and1),whichmeans
thatallnumbersarerepresentedusingonlythesetwo
digits.
•Differentnumbersystemsareusedindifferent
contexts,andeachsystemhasitsownradix.
Dr.S.Sivaranjani,AP-CSE

Common number systems and their
radices
•Binarysystem(radix2):Usestwodigits(0and1)to
representnumbers.
•Octalsystem(radix8):Useseightdigits(0-7)to
representnumbers.
•Decimalsystem(radix10):Usestendigits(0-9)to
representnumbers.
•Hexadecimalsystem(radix16):Usessixteendigits(0-9
andA-F)torepresentnumbers.
Understandingtheradixofanumbersystemis
importantforconvertingbetweendifferentsystems
andforunderstandinghowcomputersrepresentand
manipulatenumbers.
Dr.S.Sivaranjani,AP-CSE

Radix or Base
•In apositional numeral system(value of each
symbol depends on the position),
theradixorbaseis the number of
uniquedigits, including the digit zero, used to
represent numbers.
•Eg: Decimal number system:
–Uses 10 symbols (0,1,2,3,4,5,6,7,8,9)
–Hence radix or base = 10
Dr.S.Sivaranjani,AP-CSE

Positional Number System
•Another representation of a number:
a
nr
n
+a
n-1r
n-1
+…+a
1r
1
+a
0r
0
+a
-1r
-1
+a
-2r
-2
+…+a
-mr
-m
•a
j–coefficients
•j –place value/ positional value
•r –radix or base
•Eg: 567.28(decimal number)
–567.28 = 5x10
2
+6x10
1
+7x10
0
+2x10
-1
+8x10
-2
Dr.S.Sivaranjani,AP-CSE

Radix -2 (Binary Numbers)
•Symbols Used: 0,1
•Base: 2
Dr.S.Sivaranjani,AP-CSE

Radix -8 (Octal Numbers)
•Symbols Used: 0,1,2,3,4,5,6,7
•Base: 8
Dr.S.Sivaranjani,AP-CSE

Radix –10 (Decimal Numbers )
•Symbols Used: 0,1,2,3,4,5,6,7,8,9
•Base: 10
Dr.S.Sivaranjani,AP-CSE

Radix –16 (Hexadecimal Numbers)
•Symbols Used: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
•Base: 16
Dr.S.Sivaranjani,AP-CSE

Example
•The number “twenty-seven” can be represented in
different ways :
–IIIII IIIIIIIIIIIIIIIIIIIIII (sticks or unary code)
–27 (radix-10 or decimal code)
–11011 (radix-2 or binary code)
–XXVII (roman numerals)
•The use of radix-2 ( binary) numbers became popular with
the onset of electronic computers,
–binary digits or bits, having only two possible values 0 and 1, is
compatible with electronic signals
•Radix-8 (octal) and radix-16 (hexadecimal) numbers have
been used as shorthand notation for binary numbers.
Dr.S.Sivaranjani,AP-CSE

General representation
•Usually first 10 symbols in a number system of radix
r is represented by the symbols of decimal number
system and for the 11
th
symbol it starts with the
symbols of English alphabets.
–Eg:
•Radix-6 , Symbols: 0,1,2,3,4,5
•Radix-19, Symbols:0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I.
•To distinguish a number represented in a particular
number system, the number is usually written by
enclosing it in a parenthesis with a subscript of r.
–Eg:
•(56)
8 –octal
•(56)
10–decimal
•(1011)
2-binary
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(Conversion from base-r to decimal)
•Conversion of any base-r number to decimal:
–Multiply each digit with its weight(radix raised to
its positional value) to get the resultant value of
each symbol.
–Add all the resultant symbol values.
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(Binary to decimal number)
•100.111
(100.111)
2=1x2
2
+0x2
1
+0x2
0
+1x2
-1
+1x2
-2
+1x2
-3
= 4+0+0+0.5+0.25+0.125
= (4.875)
10
Dr.S.Sivaranjani,AP-CSE

To convert the binary number 11011.11 to decimal,
we can use the following method:
•Separate the integer and fractional parts of the binary number:
•Integer part: 11011
•Fractional part: 0.11
1.Convert the integer part to decimal by using the positional notation
of the binary system:11011 in binary equals
1 x 2^4 + 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 1 x 2^0= 16 + 8 + 0 + 2 + 1= 27
in decimal
2.Convert the fractional part to decimal by using the positional
notation of the binary system:
0.11 in binary equals 1 x 2^-1 + 1 x 2^-2= 0.5 + 0.25= 0.75 in decimal
3.Add the decimal values of the integer and fractional parts to get
the final decimal value:27 + 0.75= 27.75 in decimal
Therefore, the binary number 11011.11 is equal to the decimal
number 27.75.
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(Octal to decimal number)
•517.35
(517.35)
8=5x8
2
+1x8
1
+7x8
0
+3x8
-1
+5x8
-2
= 320+8+7+0.375+0.078125
= (335.453125)
10
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(Hexadecimal to decimal number)
•786.BC
(786.BC)
16=7x16
2
+8x16
1
+6x16
0
+Bx16
-1
+Cx16
-2
= 1792+128+6+0.6875+0.046875
= (1926.734375)
10
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(Conversion from decimal to base-r)
•Conversion of a decimal integer to a number in
base r:
–Divide the integer and all its successive quotients by r
–accumulate the remainder in reverse order
–Range of remainder: 0 to r-1
•Conversion of a decimal fraction to a number in
base r:
–Multiply the fraction by r and its successive remainder
by r
–accumulate the quotients in the same order
–Range of coefficients: 0 to r-1
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(decimal to binary number)
•343.392
(343)
10= (101010111)
2
0.392x2=0.784
0.784x2=1 .568
0.568x2=1.136
0.136x2=0 .272
0.272x2=0 .544
0.544x2=1.088
2343
2171-1
285-1
242-1
221-0
210-1
2 5-0
2 2-1
1-0
(0.392)
10= (0.011001…)
2
Ans: (343.392)
10= (101010111.011001)
2
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(decimal to octal number)
•153.513
(153)
10= (231)
8
0.513x8=4.104
0.104x8=0 .832
0.832x8=6.656
0.656x8=5 .248
0.248x8=1 .984
0.984x8=7.872
8153
819-1
2-3
(0.513)
10= (0.406517…)
8
Ans: (153.513)
10= (231.406517)
8
Dr.S.Sivaranjani,AP-CSE

Conversion between Number Systems
(decimal to hexadecimal number)
•487.365
(487)
10= (1E7)
16
0.365x16=5.84
0.84x16=13 .44
0.44x16=7.04
0.04x16=0 .64
0.64x16=10 .24
0.24x16=3.84
16487
1630-7
1-E
(0.365)
10= (0.5D70A3…)
16
Ans: (487.365)
10= (1E7.5D70A3)
16
Dr.S.Sivaranjani,AP-CSE

Conversion from Binary to Octal and
Octal to Binary
•Conversion of a binary number to a octal number:
–Keep splitting the binary number into 3 bits from right to
left before radix point and left to right after radix point.
–If the leftmost part before radix point has lesser than 3
bits, add 0s to fill the places.
–If the rightmost part after radix point has lesser than 3 bits,
add 0s to fill the places.
–Write the corresponding octal symbol for each 3 bits and
accumulate them.
•Conversion of a octal number to a binary number:
–Write the 3 bit binary equivalent of each octal number and
accumulate them.
Dr.S.Sivaranjani,AP-CSE

Conversion from Binary to Octal
•10110001101011.111100000110
–Splitting the numbers into 3 bits:
010 110 001 101 011 . 111 100 000 110
2 6 1 5 3 . 7 4 0 6
–Answer:
(10110001101011.111100000110)
2=(26153.7406)
8
Dr.S.Sivaranjani,AP-CSE

Conversion from Octal to Binary
•673.124
–Writing 3-bit binary equivalent for each number.
6 7 3 . 1 2 4
110 111 011 001 010 100
–Answer: (673.124)
8=(110111011.001010100)
2
Dr.S.Sivaranjani,AP-CSE

Conversion from Binary to Hexadecimal
and Hexadecimal to Binary
•Conversion of a binary number to a hexadecimal number:
–Keep splitting the binary number into 4 bits from right to left
before radix point and left to right after radix point.
–If the leftmost part has lesser than 4 bits, add 0s to fill the
places.
–If the rightmost part after radix point has lesser than 4 bits, add
0s to fill the places.
–Write the corresponding hexadecimal symbol for each 4 bits and
accumulate them.
•Conversion of a hexadecimal number to a binary number:
–Write the 4 bit binary equivalent of each hexadecimal number
and accumulate them.
Dr.S.Sivaranjani,AP-CSE

Conversion from Binary to Hexadecimal
•10110001101011.111100000110
–Splitting the numbers into 4 bits:
0010 1100 0110 1011 . 1111 0000 0110
2 C 6 B . F 0 6
–Answer:
(10110001101011.111100000110)
2=(2C6B.F06)
16
Dr.S.Sivaranjani,AP-CSE

Conversion from Hexadecimal to Binary
•306.D
–Writing 4-bit binary equivalent for each number.
3 0 6 . D
0011 0000 0110 . 1101
–Answer: (306.D)
16=(001100000110.1101)
2
Dr.S.Sivaranjani,AP-CSE

Dr.S.Sivaranjani,AP-CSE

Dr.S.Sivaranjani,AP-CSE
Complements of Numbers
(Diminished Radix complement ,Radix
Complement)

Complement
•There are two types of complements for each
base-r number system:
–Radix complement (or) r’scomplement
–Diminished radix complement (or) (r-1)’s
complement
•Complements are used in digital computers
for simplifying the subtraction operation.
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement/ Diminished Radix
Complement
•The (r-1)’s complement of N:
(r
n
-1)-N
N –Number
r –radix /base
n –number of digits in N
(r
n
-1) is the largest number with n digits in base r
Hence, subtraction is between the number N from the largest number
with n digits.
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement of Binary Number/
1’s Complement
•N = 1011000; r=2
n = 7 ; r –1 = 1 (1’s complement)
1’s complement = (2
7
-1)
10-(1011000)
2
= ( 128 -1)
10–(1011000)
2
= ( 127)
10–(1011000)
2
= (1111111)
2–(1011000)
2
= 0100111
•N = 0101101 ; r=2
n =7
1’s complement = 1111111 –0101101
= 1010010
Largest 7 digit binary number
Dr.S.Sivaranjani,AP-CSE

1’s complement –Another Method
•1’s complement of a binary number is formed
by
–changing 1’s to 0’s and 0’s to 1’s
•Eg: N = 1011000
–1’s complement is 0100111
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement of Octal Number/
7’s Complement
•N = 563 ; r = 8
n= 3; r-1 = 7 (7’s complement)
7’s complement = (8
3
-1)
10-(563)
8
= (512-1)
10-(563)
8
= (511)
10-(563)
8
= (777)
8-(563)
8
= 214 Largest 3 digit octal number
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement of Decimal Number/
9’s Complement
•N = 546700 ; r = 10
n= 6; r-1 = 9 (9’s complement)
9’s complement = (10
6
-1)
10–(546700)
10
= (1000000-1)
10–(546700)
10
= (999999)
10–(546700)
10
= 453299 Largest 6 digit decimal
number
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement of HexdecimalNumber/
15’s Complement
•N = C3DF ; r= 16
n= 4; r-1 = 15 (15’s complement)
15’s complement = (16
4
-1)
10–(C3DF)
16
= (65536-1)
10–(C3DF)
16
= (65535)
10–(C3DF)
16
= (FFFF)
16–(C3DF)
16
= 3C20
Largest 4 digit hexadecimal
number
Dr.S.Sivaranjani,AP-CSE

r’sComplement/Radix Complement
•The r’scomplement of N:
r
n
-N for N ≠ 0
0 for N = 0
N –Number
r –radix /base
n –number of digits in N
•r’scomplement is obtained by adding 1 to (r-1)’s complement:
r
n
-N = [(r
n
-1)-N]+1
•Note: It is better to do (r-1)’s complement first for r’scomplement since it is
easy to do the subtraction in (r-1)’s complement(no borrow problem!).
Dr.S.Sivaranjani,AP-CSE

r’sComplement of Binary Number/ 2’s
Complement
•N = 1011000 ; r=2
n = 7 ; r = 2 (2’s complement)
1’s complement = (1111111)
2–(1011000)
2
= 0100111
2’s complement = 1’s complement + 1
= 0100111 + 1
= 0101000
Dr.S.Sivaranjani,AP-CSE

2’s complement –Another Method
•2’s complement of a binary number is formed by
–Scan the numbers from right to left
–Till the first ‘1’ is found write the digits as such.
–After the first ‘1’, invert all the digits.
•Eg: N = 1011000
–Writing the digits till 1
st
‘1’ from right to left :
---1 0 0 0
–Inverting the rest of the numbers
0 1 0 1 0 0 0
–Hence 2’s complement is : 0101000
•Eg: N = 1011001
–Writing the digits till 1
st
‘1’ from right to left :
------1
–Inverting the rest of the numbers
0 1 0 0 1 1 1
–Hence 2’s complement is : 0100111
Dr.S.Sivaranjani,AP-CSE

r’sComplement of Octal Number/
8’s Complement
•N = 563 ; r = 8
n= 3; r = 8 (8’s complement)
7’s complement = (777)
8-(563)
8
= 214
8’s complement = 7’s complement + 1
= 214 +1
= 215
Dr.S.Sivaranjani,AP-CSE

r’sComplement of Decimal Number/
10’s Complement
•N = 546700 ; r = 10
n= 6; r = 10 (10’s complement)
9’s complement = (999999)
10–(546700)
10
= 453299
10’s complement = 9’s complement + 1
= 453299 + 1
= 453300
Dr.S.Sivaranjani,AP-CSE

r’sComplement of Hexadecimal Number/
16’s Complement
•N = C3DF ; r= 16
n= 4; r = 16 (16’s complement)
15’s complement = (FFFF)
16–(C3DF)
16
= 3C20
16’s complement = 15’s complement + 1
= 3C20 + 1
= 3C21
Dr.S.Sivaranjani,AP-CSE

Complement of a number with radix
point
•If the original number N contains a radix point,
–Temporarily remove the point to perform
complement.
–The radix point is then restored to the
complemented number in the same relative
position.
Dr.S.Sivaranjani,AP-CSE

Complement with radix point (Base-2)
•N = 1101.011
1101.011= 1101011 x 2
-3
1’s complement of 1101011=1111111-1101011
= 0010100
2’s complement of 1101011 = 0010100 + 1
= 0010101
1’s complement of 1101.011= 0010100 x 2
-3
= 0010.100
2’s complement of 1101.011 = 0010101 x2
-3
= 0010.101
Dr.S.Sivaranjani,AP-CSE

Complement with radix point (Base-8)
•N = 323.64
323.64= 32364x 8
-2
7’s complement of 32364 =77777-32364
= 45413
8’s complement of 32364 = 45413 + 1
= 45414
7’s complement of 323.64 = 45413 x 8
-2
= 454.13
8’s complement of 323.64 = 45414x8
-2
= 454.14
Dr.S.Sivaranjani,AP-CSE

Complement with radix point (Base-10)
•N = 325.93
325.93= 32593x 10
-2
9’s complement of 32593 =99999-32593
=67406
10’s complement of 32593 = 67406 + 1
= 67407
9’s complement of 325.93 = 67406 x 10
-2
= 674.06
10’s complement of 325.93 = 67407 x10
-2
= 674.07
Dr.S.Sivaranjani,AP-CSE

Complement with radix point (Base-16)
•N = ABC.3E2
ABC.3E2 = ABC3E2 x 16
-3
15’s complement of ABC3E2 =FFFFFF-ABC3E2
= 543C1D
16’s complement of ABC3E2 = 543C1D + 1
= 543C1E
15’s complement of ABC.3E2 = 543C1D x 16
-3
= 543.C1D
16’s complement of ABC.3E2 = 543C1E x16
-3
= 543.C1E
Dr.S.Sivaranjani,AP-CSE

Subtraction with Complements
r’sComplement Subtraction
•The subtraction of 2 n-digit unsigned numbers
M-N in base r can be done as follows:
–Add the minuend M to the r’scomplement of the
subtrahend N. This performs: M+(r
n
-N)=M-N+r
n
–If M≥ N, the sum will produce an end carry,r
n
,
which can be discarded. Hence the result is M-N
–If M< N, the sum does not produce an end carry
and is equal to r
n
-(N-M), which is the r’s
complement of N-M
Dr.S.Sivaranjani,AP-CSE

r’sComplement Subtraction(Base-2)
•1010100-1000011
2’s complement of 1000011=1111111-1000011+1 = 0111101
Answer =0010001
•1000011-1010100
2’s complement of 1010100=1111111-1010100+1 = 0101100
Answer =1101111 (or) -0010001
1 0 1 0 10 0
0 1 1 1 1 0 1
10 0 1 0 0 0 1
1 0 0 0 0 1 1
0 1 0 1 1 0 0
1 10 1 1 1 1
Dr.S.Sivaranjani,AP-CSE

r’sComplement Subtraction(Base-8)
•342-614
8’s complement of 614=777-614+1 = 164
Answer =526 (or) -252
•614-342
8’s complement of 342=777-342+1 = 436
Answer =252
3 4 2
1 6 4
5 2 6
6 1 4
4 3 6
12 5 2
Dr.S.Sivaranjani,AP-CSE

r’sComplement Subtraction(Base-10)
•72532-3250
10’s complement of 03250=99999-03250+1 = 96750
Answer =69282
•3250-72532
10’s complement of 72532=99999-72532+1 = 27468
Answer =30718 (or) -69282
7 2 5 3 2
9 6 7 5 0
16 9 2 8 2
0 3 2 5 0
2 7 4 68
3 0 7 1 8
Dr.S.Sivaranjani,AP-CSE

r’sComplement Subtraction(Base-16)
•CB2-672
16’s complement of 672=FFF-672+1 =98E
Answer =640
•672-CB2
16’s complement of CB2=FFF-CB2+1 = 34E
Answer =9C0 (or) -640
C B 2
9 8 E
16 4 0
6 7 2
3 4 E
9 C 0
Dr.S.Sivaranjani,AP-CSE

Subtraction with Complements
r-1’s Complement Subtraction
•The subtraction of 2 n-digit unsigned numbers M-N
in base r can be done as follows:
–Add the minuend M to the r’scomplement of the
subtrahend N.
–If M≥ N, the sum will produce an end carry, which is added
to the result since it produces a sum that is 1 less than the
correct difference(only if carry is generated).
•Removing the end carry and adding 1 to the sum is referred to as
an end-around carry.
–If M< N, the sum does not produce an end carry,whichis
the r-1’s complement of N-M
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement Subtraction(Base-2)
•1010100-1000011
1’s complement of 1000011=1111111-1000011 = 0111100
Answer =0010001
•1000011-1010100
1’s complement of 1010100=1111111-1010100 = 0101011
Answer =1101110 (or) -0010001
1 0 0 0 0 1 1
0 1 0 1 0 1 1
1 10 1 1 1 0
1 0 1 0 10 0
0 1 1 1 1 0 0
10 0 1 0 0 0 0
1
0 0 1 0 0 0 1
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement Subtraction(Base-8)
•402-314
7’s complement of 314=777-314 = 463
Answer =066
•314-402
7’s complement of 402=777-402 = 375
Answer =711 (or) -066
3 14
3 7 5
7 1 1
4 0 2
4 6 3
10 6 5
1
0 6 6
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement Subtraction(Base-10)
•4567-1234
9’s complement of 1234=99999-1234= 8765
Answer =3333
•1234-4567
9’s complement of 4567=99999-4567= 5432
Answer =6666 (or) -3333
1 2 3 4
5 4 3 2
6 6 6 6
4 5 6 7
8 7 6 5
13 3 3 2
1
3 3 3 3
Dr.S.Sivaranjani,AP-CSE

r-1’s Complement Subtraction(Base-16)
•B06-C7C
15’s complement of C7C=FFF-C7C = 383
Answer =E89 (or) -176
•C7C-B06
15’s complement of B06=FFF-B06 = 4F9
Answer =176
B 0 6
3 8 3
E 8 9
C 7 C
4 F 9
11 7 5
1
1 7 6
Dr.S.Sivaranjani,AP-CSE

Signed Binary Numbers
Dr.S.Sivaranjani,AP-CSE

Signed Binary Number Representations
•Both signed and unsigned binary numbers
consists of a string of bits when represented in
computer.
•User determines whether a number is signed or
not.
•Representation Types:
–Signed-magnitude representation
–Signed-Complement representation
•1’s Complement
•2’s Complement
Dr.S.Sivaranjani,AP-CSE

Sign-Magnitude Representation
•The number consists of two parts:
Sign bit (leftmost bit)
Magnitude bits (other than leftmost bit)
•If the leftmost bit is
0 –positive number
1 –negative number
•The negative number has the same magnitude bits as the
corresponding positive number but the sign bit is 1 rather than 0.
•Eg: 8-bit representation of ‘fifteen’
+15 –0 0001111
-15 –1 0001111
It is used in ordinary arithmetic but usually not in computer
arithmetic, since sign and magnitude bits must be handled
separately.
Dr.S.Sivaranjani,AP-CSE

1’s Complement Representation
•The negative number is the 1’s complement of
the corresponding positive number.
•Has some difficulties while used for arithmetic
operations.
•It is used in logical operations.
•There are two different representations for
zero.(i.e) 0000 and 1111 (4 bit +0 and -0).
•Eg: 8-bit representation of ‘fifteen’
+15 –00001111
-15 –11110000
Dr.S.Sivaranjani,AP-CSE

2’s Complement Representation
•The negative number is the 2’s complement of
the corresponding positive number.
•This is the most common representation used
in computer arithmetic
•Eg: 8-bit representation of ‘fifteen’
+15 –0 0001111
-15 –11110001
Dr.S.Sivaranjani,AP-CSE

2’s Complement Representation
Note: leftmost bit of the
representation acts a the sign bit (0
for positive values, 1 for negative
ones)
Dr.S.Sivaranjani,AP-CSE

Conversion of decimal numbers to
signed binary numbers
•Express decimal number -39 as 8-bit number in (a)sign-
magnitude (b)1’s complement and (c)2’s complement
representations.
–8-bit representation for +39
00100111
–(a)8-bit Sign magnitude representation for -39:
10100111
–(b) 8-bit 1’s complement representation for -39:
11011000
–(c) 8-bit 2’s complement representation for -39:
11011001
First represent the corresponding
positive number in the given number
of bits. Else the minimum number of
bits required to represent that
particular number should be taken.
Then use that
number
represented in
the required
number of bits to
find the negative
representation
Dr.S.Sivaranjani,AP-CSE

Conversion of a signed binary number
to decimal number
Determine the decimal value of signed binary number expressed
in sign-magnitude representation.
•10010101
–Computing the weights of rightmost 7 bits:
0x2
6
+0x2
5
+1x2
4
+0x2
3
+1x2
2
+0x2
1
+1x2
0
= 16+4+1=21
–Sign bit(leftmost bit) is 1.Hence it’s a negative number
–Therefore, the decimal number is -21
Dr.S.Sivaranjani,AP-CSE

Conversion of a signed binary number
to decimal number
Determine the decimal value of signed binary number expressed
in 1’s complement representation.
•00010111
–Computing the weights of the bits with the weight of the leftmost bit
as negative:
-0x2
7
+0x2
6
+0x2
5
+1x2
4
+0x2
3
+1x2
2
+1x2
1
+1x2
0
= 16+4+2+1= +23
-Therefore, the decimal number is +23
•11101000 (complement of the previous question)
–Computing the weights of the bits with the weight of the leftmost bit
as negative:
-1x2
7
+1x2
6
+1x2
5
+0x2
4
+1x2
3
+0x2
2
+0x2
1
+0x2
0
= -128+64+32+8=-24
-Adding 1 to the result (i.e)-24+1=-23
-Therefore, the decimal number is -23
Negative numbers alone add
1 if 1’s complement
representationDr.S.Sivaranjani,AP-CSE

Conversion of a signed binary number
to decimal number
Determine the decimal value of signed binary number expressed
in 2’s complement representation.
•01010110
–Computing the weights of the bits with the weight of the leftmost bit
as negative:
-0x2
7
+1x2
6
+0x2
5
+1x2
4
+0x2
3
+1x2
2
+1x2
1
+0x2
0
= 64+16+4+2= +86
-Therefore, the decimal number is +86
•10101010 (complement of the previous question)
–Computing the weights of the bits with the weight of the leftmost bit
as negative:
-1x2
7
+0x2
6
+1x2
5
+0x2
4
+1x2
3
+0x2
2
+1x2
1
+0x2
0
= -128+32+8+2=-86
-Therefore, the decimal number is -86
Need not add 1 like 1’s
complement representation
Dr.S.Sivaranjani,AP-CSE

3-bit representation of signed numbers
NoPossible
3-bit
represent
ations
Ifonly
positive
numbers
represented
Ifnegative
numbers also
should be
represented
(sign-
magnitude)
Ifnegative
numbers also
should be
represented
(1’s
complement)
Ifnegative
numbers also
should be
represented
(2’s
complement)
1000 0 +0 +0 0
2001 1 +1 +1 +1
3010 2 +2 +2 +2
4011 3 +3 +3 +3
5100 4 -0 -3 -4
6101 5 -1 -2 -3
7110 6 -2 -1 -2
8111 7 -3 -0 -1
With the available combinations of binary numbers for a given number of bits,
positive and negative numbers must be represented(FOR SIGNED NUMBERS)!Dr.S.Sivaranjani,AP-CSE

Arithmetic operation with the Binary Numbers
Dr.S.Sivaranjani,AP-CSE

Binary Addition
•Addition
–The two numbers in addition:
•Augend
•Addend
–Result is:
•Sum
–Eg:
–Note: Generally, negative numbers are considered in 2’s
complement representation
0 0 0 00 1 1 1 Augend
+0 0 0 0 0 1 0 0 Addend
0 0 0 01 0 1 1 Sum
Dr.S.Sivaranjani,AP-CSE

Binary Addition
•Both numbers are positive (consider 8 bit)
•Positive number with magnitude larger than
negative number
0 0 0 00 1 1 1 (+7)
+0 0 0 0 0 1 0 0+(+4)
0 0 0 01 0 1 1 11
0 0 0 01 1 1 1 (+15)
+1 1 1 11 0 1 0+(-6)
10 0 0 0 1 0 0 1 9
Discard CarryDr.S.Sivaranjani,AP-CSE

Binary Addition
•Negative number with magnitude larger than
positive number
•Both numbers are negative
0 0 0 10 0 0 0 (+16)
+1 1 1 0 1 0 0 0+(-24)
1 1 1 11 0 0 0 -8
11 1 11 0 1 1 (-5)
+1 1 1 10 1 1 1+(-9)
11 1 1 10 0 1 0 -14
Discard Carry
Dr.S.Sivaranjani,AP-CSE

Binary Addition
•Overflow condition
–When two numbers are added and the number of bits required to
represent that sum exceeds the number of bits in the two numbers, an
overflow condition occurs.
–It can occur only if both numbers are positive or both numbers are
negative.
–If the sign bit of the result is different than the sign bit of the numbers
that are added, overflow is indicated.
0 1 1 11 1 0 1 (+125)
+0 0 1 11 0 1 0+(+58)
1 0 1 10 1 1 1 183
Incorrect Sign bit
Dr.S.Sivaranjani,AP-CSE

Binary Subtraction
•Special case of addition is subtraction
•Subtraction
–The two numbers in subtraction:
•Minuend
•Subtrahend
–Result is:
•Difference
•Eg:
1 0 1 1 0 1Minuend
+1 0 0 1 1 1Subtrahend
0 0 0 1 1 0Difference
Dr.S.Sivaranjani,AP-CSE

Binary Subtraction
•The sign of the number is changed by taking
2’s complement
•To subtract 2 numbers
–take the 2’s complement of the subtrahend and
add.
–Discard any final carry
Dr.S.Sivaranjani,AP-CSE

Binary Subtraction
•00001000-00000011
–2’s complement of 00000011=11111101
0 0 0 01 0 0 0 (+8)
+1 1 1 11 1 0 1+(-3)
10 0 0 00 1 0 1 +5
Dr.S.Sivaranjani,AP-CSE

Binary Multiplication
•Multiplication
–The numbers in multiplication:
•Multiplicand
•Multiplier
–Result is:
•Product
•(Partial Product)
Dr.S.Sivaranjani,AP-CSE

Binary Multiplication
•1011 x 101
1 0 1 1Multiplicand(11)
x 1 0 1Multiplier(5)
1 0 1 1Partial Product
0 0 0 0 Partial Product
1 0 1 1 Partial Product
1 1 0 1 1 1Product(55)
Dr.S.Sivaranjani,AP-CSE

Binary Division
•Division
–The numbers in division:
•Dividend
•Divisor
–Result is:
•Quotient
•Remainder
Dr.S.Sivaranjani,AP-CSE

Binary Division
•11000101 ÷1010
1 0 0 1 1 Quotient(19)
10101 1 0 0 0 1 0 1Divident(197)
1 0 1 0
0 1 0 0
0 0 0 0
1 0 0 1
0 0 0 0
10 0 1 0
1 0 1 0
1 0 0 0 1
1 0 10
1 1 1 Remainder(7)
Divisor(10)
Dr.S.Sivaranjani,AP-CSE

Binary Codes
( BCD, 8421 code,Graycode,ASCII)
Dr.S.Sivaranjani,AP-CSE

Binary Codes
•Any discrete elements of information that is distinct
among a group of quantities can be represented with
binary codes
•Sample Binary Codes:
–Binary Coded Decimal(BCD)/8421
–Gray Code
–Excess-3 Code
–2421 Code
–ASCII Code
.
.
.
Dr.S.Sivaranjani,AP-CSE

Binary Coded Decimal(BCD)/8421
•Straight binary assignment of the decimal numbers.
•It is a weighted code (codeswhich obey the
positionalweightprinciple.)
•10 decimal digits requires 4 bits for representation. But 6
out of 16 4-bit possible combination remains unassigned.
–A number with k decimal digits will require 4k bits in BCD
•Eg:
–(185)
10= (0001 1000 0101)
BCD = (10111001)
2
•Applications: Digital clocks, digital meters, Seven segment
display etc…(simplify the display of decimal numbers)
•This code is not very efficient but useful if only limited
processing is required.
Dr.S.Sivaranjani,AP-CSE

Decimal & BCD
DECIMAL BCD
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 00 0 1 0 0 0 0
Dr.S.Sivaranjani,AP-CSE

BCD Addition
•Add 2 BCD numbers using the rules for binary
addition
•If a 4-bit sum is equal or less than 9, it’s a valid
BCD number
•If a 4-bit sum is greater than 9 or if a carry out of
the 4-bit group is generated, it is an invalid result.
–Add 6(0110) to the 4-bit sum in order to skip the
invalid states.
–If a carry results when 6 is added, simply add the carry
to the next 4-bit group
Dr.S.Sivaranjani,AP-CSE

BCD Addition
•0110 0111 + 0101 0011
0 1 1 00 1 1 1 67
+0 1 0 10 0 1 1+53
1 0 1 11 0 1 0
0 1 1 00 1 1 0
0 0 0 10 0 1 00 0 0 0 120
Invalid BCD
Invalid BCD
Dr.S.Sivaranjani,AP-CSE

BCD Addition
•The sign of the decimal number is represented
using 4 bits
–0000 represents positive
–1001 represents negative
•Sign-magnitude is seldom used in computers
•Sign-complement uses 9’s or 10’s complement
Dr.S.Sivaranjani,AP-CSE

BCD Addition (10’s complement)
•(+ 0011 0111 0101) + (-0010 0100 0000)
–0011 0111 0101 –> 375
–0010 0100 0000 –> 240
–10’s complement of 0240 = 9999-0240+1= 9760
–Answer:
(+0011 0111 0101) + (-0010 0100 0000) = (+0001 0011 0101)
0 3 7 5
9 7 6 0
10 1 3 5
Discard Carry
Sign
Dr.S.Sivaranjani,AP-CSE

BCD Subtraction
•At first the decimal equivalent of the given
Binary Coded Decimal (BCD) codes are found
out.
•Then the 10’s compliment of the subtrahend is
done and then that result is added to the
number from which the subtraction is to be
done.
•Discard Carry if generated
•Note: If 9’s complement is used, carry is added to the
result of subtraction!
Dr.S.Sivaranjani,AP-CSE

BCD Subtraction (9’s complement)
•0101 0001 − 0010 0001
–0101 0001 -> 51
–0010 0001 -> 21
–9’s complement of 21 = 99-21 = 78
–30 -> 0011 0000
–Answer: 0101 0001 − 0010 0001 = 0011 0000
5 1
+7 8
12 9
1
3 0
Carry
Carry generated added to
result
Dr.S.Sivaranjani,AP-CSE

Gray Code
•Un-weighted code
•Important Feature:
–It exhibits one a single
bit change from one
code word to the next
in sequence
DecimalBinary Gray
0 0 0 0 00 0 0 0
1 0 0 0 100 0 1
2 0 0 1 00 0 1 1
3 0 0 1 10 0 1 0
4 0 1 0 00 1 1 0
5 0 1 0 10 1 1 1
6 0 1 1 00 1 0 1
7 0 1 1 10 1 0 0
8 10 0 01 1 0 0
9 1 0 0 11 1 0 1
10 1 0 10 11 1 1
11 1 0 1 11 1 1 0
12 1 1 0 01 0 1 0
12 1 1 0 11 0 1 1
14 1 1 1 01 0 0 1
15 1 1 1 11 0 0 0
Dr.S.Sivaranjani,AP-CSE

Binary to Gray Code Conversion
•The MSB in the gray code is the same as the
corresponding MSB in the binary number
•Going from left to right, add each adjacent
pair of binary code bits to get the next gray
code bit.
•Discard Carries.
Dr.S.Sivaranjani,AP-CSE

Binary to Gray Code Conversion
•Binary number = 10110
•(10110)
2=(11101)
Gray
•Note: Can perform XOR operation instead of addition. Hence
need not think about carry!
1 0 1 1 0 Binary
+ + + +
1 1 1 0 1 Gray
1+0 0+1 1+1 1+0
Dr.S.Sivaranjani,AP-CSE

Gray to Binary Code Conversion
•MSB in the binary code is the same as the
corresponding bit in the gray code.
•Add each binary code bit generated to the
next gray code bit in the next adjacent
position.
•Discard carries.
Dr.S.Sivaranjani,AP-CSE

Gray to Binary Code Conversion
•Gray code = 11101
•(11101)
Gray= (10110)
2
•Note: Can perform XOR operation instead of addition. Hence
need not think about carry!
1 1 1 0 1 Gray
+ + + +
1 0 1 1 0 Binary
1+1 0+1 1+0 1+1
Dr.S.Sivaranjani,AP-CSE

Excess-3 Code
•Un-weighted Code
•Codes are obtained from
the corresponding decimal
value plus 3 in 4-bit binary
•Self complementing
code(9’s complement of a
number is directly obtained
by changing 1s to 0s and 0s
to 1s).
–9’s complement of 4 is 5.
–9’s complement of 3 is 6
Decimal BCD Excess-3
[(BCD+3) in
binary]
0 0 0 0 0 0 0 1 1
1 0 0 0 1 0 1 0 0
2 0 0 1 0 0 1 0 1
3 0 0 1 1 0 1 1 0
4 0 1 0 0 0 1 1 1
5 0 1 0 1 10 0 0
6 0 1 1 0 1 0 0 1
7 0 1 1 1 1 0 1 0
8 10 0 0 1 0 1 1
9 1 0 0 1 1 10 0
10 0001 000001000011
Dr.S.Sivaranjani,AP-CSE

Converting Decimal to Excess-3
•(23)
10
–Add both the digits separately by 3
•2+3 =5
•3+3 = 6
–Convert each corresponding decimal number to
equivalent 4 bit binary code
•5 –0101
•6 –0110
–Answer: (23)
10=(0101 0110)
XS-3
Dr.S.Sivaranjani,AP-CSE

Converting Decimal to Excess-3
•(359.8)
10
–Add both the digits separately by 3
•3+3 =6
•5+3 = 8
•9+3 =12
•8 +3=11
–Convert each corresponding decimal number to equivalent
4 bit binary code
•6 –0110
•8 –1000
•12 –1100
•11 –1011
–Answer: (359.8)
10=(0110 1000 1100.1011)
XS-3
Dr.S.Sivaranjani,AP-CSE

American Standard Code for
Information Interchange (ASCII)
•An alphanumeric character set is a set of
elements that includes
–10 decimal digits
–26 letters of alphabets
–a number of special characters
•Uses 7 bit code and 128 characters
–Eg: A -1000001
Dr.S.Sivaranjani,AP-CSE

ASCII
•It contains
–94 graphic characters that can be printed
•26 uppercase letters( A –Z)
•26 lowercase letters( a –z)
•10 numerals ( 0 –9 )
•32 special printable characters such as %,*,$ …
–34 non-printable characters used for various
control functions.
Totally 128
(94+34) characters
Dr.S.Sivaranjani,AP-CSE

ASCII
•Control Characters
–Used for routing data and arranging printed text into prescribed
format
–Three types of control characters
•Format Effectors
–Characters that affect the layout of printing
–They include word processor and type writer controls:
»Backspace (BS)
»Horizontal tabulation (HT)
»Carriage return (CR)
•Information Separators
–Separate data into divisions such as paragraphs and pages
–They include:
»Record separator(RS)
»File separator(FS)
Dr.S.Sivaranjani,AP-CSE

ASCII
•Communication Control Characters
–Useful during the transmission of text between remote
devices so that it can be distinguished from other messages
using the same communication channel before it and after it
»Start of Text (STX)
»End of Text (ETX)
•Mostly computers manipulate an 8-bit quantity as a
single quantity. Hence it is stored as one ASCII
character per byte
–Extra bit is used for other purposes depending on the
application
Dr.S.Sivaranjani,AP-CSE

ASCII TABLE
Dr.S.Sivaranjani,AP-CSE
Tags