SlideShare a Scribd company logo
19Z204- Digital Design
Dr.S.Sivaranjani,AP-CSE
Course Topics(Unit –I)
• Introduction to Digital Systems
• Number systems
• Number-Base conversion
• Complements of Numbers (Diminished Radix
complement ,Radix Complement)
• Signed Binary Numbers
• Arithmetic operation with the Binary Numbers
• Binary Codes ( BCD, 8421 code,Gray code,ASCII)
Dr.S.Sivaranjani,AP-CSE
• Digital Systems are part of your daily activities.
• Everything in Digital(High Resolution Display) : Camera,
Laptop, Mobile phones, Tab- we are using Digital Electronics
Dr.S.Sivaranjani,AP-CSE
Data processing
Data transmission
Device control
Digital
Systems
Made or build using
Introduction to Digital Systems
• Digital Devices have GUI [ Graphical User
Interface]
• Enable the devices to execute commands that
appear to the user to be simple but which
involves precise execution of a sequence of
complex internal instructions
• Digital Systems are fast, accurate and
consume less power.
Dr.S.Sivaranjani,AP-CSE
Digital Systems
• Stemming from word “Digit” [means 0,1,2,3…]
• Use digital signals or information to operate
• Digital Signals : are discrete signals that
represent information in the form of binary
digits (bits) which can take only one of two
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
[storage devices are used
to store data and
instructions, such as
memory chips and hard
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
• A digital system is a system that processes
information in a digital form.
• It consists of electronic devices that
manipulate digital signals, such as binary
code, using a set of logic gates and algorithms.
• These devices include microprocessors,
microcontrollers, digital signal processors, and
other digital integrated circuits.
Dr.S.Sivaranjani,AP-CSE
Applications of digital system
Digital systems have a wide range of applications in various fields, including:
Communication systems:
• Digital systems are used in communication systems, such as cellular
phones, satellites, and the internet.
• They enable reliable transmission and reception of data and voice signals
over long distances.
Control systems:
• Digital systems are used in control systems, such as robotics, process
control, and automotive control systems.
• They allow for precise control of devices and processes, ensuring optimal
performance.
Digital signal processing:
• Digital systems are used in digital signal processing applications, such as
audio and video processing, image and speech recognition, and radar and
sonar systems.
Dr.S.Sivaranjani,AP-CSE
Medical devices:
• Digital systems are used in medical devices, such
as pacemakers, MRI machines, and digital X-ray
machines.
• They enable accurate and reliable diagnostic and
treatment procedures.
Consumer electronics:
• Digital systems are used in consumer electronics,
such as smartphones, tablets, laptops, and smart
TVs.
• They provide a wide range of functions and
capabilities, such as multimedia playback,
internet access, and gaming.
Dr.S.Sivaranjani,AP-CSE
Industrial automation:
• Digital systems are used in industrial automation
systems, such as manufacturing plants, assembly
lines, and logistics systems.
• They enable efficient and automated control of
production and logistics processes.
Defense and aerospace:
• Digital systems are used in defense and
aerospace applications, such as military
communication systems, guidance and control
systems for aircraft and missiles, and satellite
communication and navigation systems.
Dr.S.Sivaranjani,AP-CSE
Number System
Dr.S.Sivaranjani,AP-CSE
General Representation
• A number is represented as
a5a4a3a2a1a0.a-1a-2a-3a-4
• . - radix point
• aj – coefficients(symbols used in a number representation)
• j – place value
• Example:
– Decimal number: 567.28
Dr.S.Sivaranjani,AP-CSE
Radix or Base
• The radix of a number system is also known as
its base or its numerical base.
• It refers to the number of unique digits or
symbols used in the system to represent
numbers.
• For example, the decimal system that we use
in everyday life has a radix of 10 because it
uses 10 digits (0-9) to represent numbers.
Dr.S.Sivaranjani,AP-CSE
• The radix of a number system is an integer greater than
1.
• The value of the radix determines the range of values
that can be represented using the system, as well as
the way in which numbers are written and
manipulated.
• For example, in a binary system with a radix of 2, there
are only two possible digits (0 and 1), which means
that all numbers are represented using only these two
digits.
• Different number systems are used in different
contexts, and each system has its own radix.
Dr.S.Sivaranjani,AP-CSE
Common number systems and their
radices
• Binary system (radix 2): Uses two digits (0 and 1) to
represent numbers.
• Octal system (radix 8): Uses eight digits (0-7) to
represent numbers.
• Decimal system (radix 10): Uses ten digits (0-9) to
represent numbers.
• Hexadecimal system (radix 16): Uses sixteen digits (0-9
and A-F) to represent numbers.
Understanding the radix of a number system is
important for converting between different systems
and for understanding how computers represent and
manipulate numbers.
Dr.S.Sivaranjani,AP-CSE
Radix or Base
• In a positional numeral system(value of each
symbol depends on the position),
the radix or base is the number of
unique digits, 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:
anrn+an-1rn-1+…+a1r1+a0r0+a-1r-1+a-2r-2+…+a-mr-m
• aj – coefficients
• j – place value/ positional value
• r – radix or base
• Eg: 567.28(decimal number)
– 567.28 = 5x102+6x101+7x100+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 IIIII IIIII IIIII IIIII II (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 11th 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=1x22+0x21+0x20+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=5x82+1x81+7x80+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=7x162+8x161+6x160+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.392 x 2 = 0 .784
0.784 x 2 = 1 .568
0.568 x 2 = 1 .136
0.136 x 2 = 0 .272
0.272 x 2 = 0 .544
0.544 x 2 = 1 .088
2 343
2 171 - 1
2 85 - 1
2 42 - 1
2 21 - 0
2 10 - 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.513 x 8 = 4 .104
0.104 x 8 = 0 .832
0.832 x 8 = 6 .656
0.656 x 8 = 5 .248
0.248 x 8 = 1 .984
0.984 x 8 = 7 .872
8 153
8 19 - 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.365 x 16 = 5 .84
0.84 x 16 = 13 .44
0.44 x 16 = 7 .04
0.04 x 16 = 0 .64
0.64 x 16 = 10 .24
0.24 x 16 = 3 .84
16 487
16 30 - 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’s complement
– 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:
(rn-1)-N
 N – Number
 r – radix /base
 n – number of digits in N
 (rn-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 = (27-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 = (83-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 = (106-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 Hexdecimal Number/
15’s Complement
• N = C3DF ; r= 16
n= 4; r-1 = 15 (15’s complement)
15’s complement = (164-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’s Complement/Radix Complement
• The r’s complement of N:
rn-N for N ≠ 0
0 for N = 0
 N – Number
 r – radix /base
 n – number of digits in N
• r’s complement is obtained by adding 1 to (r-1)’s complement:
rn-N = [(rn-1)-N]+1
• Note: It is better to do (r-1)’s complement first for r’s complement since it is
easy to do the subtraction in (r-1)’s complement(no borrow problem!).
Dr.S.Sivaranjani,AP-CSE
r’s Complement 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 1st ‘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 1st ‘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’s Complement 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’s Complement 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’s Complement 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’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’s complement of the
subtrahend N. This performs: M+(rn-N)=M-N+rn
– If M≥ N, the sum will produce an end carry,rn,
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 rn-(N-M), which is the r’s
complement of N-M
Dr.S.Sivaranjani,AP-CSE
r’s Complement 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 1 0 0
0 1 1 1 1 0 1
1 0 0 1 0 0 0 1
1 0 0 0 0 1 1
0 1 0 1 1 0 0
1 1 0 1 1 1 1
Dr.S.Sivaranjani,AP-CSE
r’s Complement 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
1 2 5 2
Dr.S.Sivaranjani,AP-CSE
r’s Complement 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
1 6 9 2 8 2
0 3 2 5 0
2 7 4 6 8
3 0 7 1 8
Dr.S.Sivaranjani,AP-CSE
r’s Complement 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
1 6 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’s complement 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,which is
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 1 0 1 1 1 0
1 0 1 0 1 0 0
0 1 1 1 1 0 0
1 0 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 1 4
3 7 5
7 1 1
4 0 2
4 6 3
1 0 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
1 3 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
1 1 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:
0x26+0x25+1x24+0x23+1x22+0x21+1x20 = 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:
-0x27+0x26+0x25+1x24+0x23+1x22+1x21+1x20 = 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:
-1x27+1x26+1x25+0x24+1x23+0x22+0x21+0x20 = -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
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 2’s complement representation.
• 01010110
– Computing the weights of the bits with the weight of the leftmost bit
as negative:
-0x27+1x26+0x25+1x24+0x23+1x22+1x21+0x20 = 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:
-1x27+0x26+1x25+0x24+1x23+0x22+1x21+0x20 = -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
No Possible
3-bit
represent
ations
If only
positive
numbers
represented
If negative
numbers also
should be
represented
(sign-
magnitude)
If negative
numbers also
should be
represented
(1’s
complement)
If negative
numbers also
should be
represented
(2’s
complement)
1 000 0 +0 +0 0
2 001 1 +1 +1 +1
3 010 2 +2 +2 +2
4 011 3 +3 +3 +3
5 100 4 -0 -3 -4
6 101 5 -1 -2 -3
7 110 6 -2 -1 -2
8 111 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 0 0 1 1 1 Augend
+ 0 0 0 0 0 1 0 0 Addend
0 0 0 0 1 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 0 0 1 1 1 (+7)
+ 0 0 0 0 0 1 0 0 + (+4)
0 0 0 0 1 0 1 1 11
0 0 0 0 1 1 1 1 (+15)
+ 1 1 1 1 1 0 1 0 + (-6)
1 0 0 0 0 1 0 0 1 9
Discard Carry Dr.S.Sivaranjani,AP-CSE
Binary Addition
• Negative number with magnitude larger than
positive number
• Both numbers are negative
0 0 0 1 0 0 0 0 (+16)
+ 1 1 1 0 1 0 0 0 + (-24)
1 1 1 1 1 0 0 0 -8
1 1 1 1 1 0 1 1 (-5)
+ 1 1 1 1 0 1 1 1 + (-9)
1 1 1 1 1 0 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 1 1 1 0 1 (+125)
+ 0 0 1 1 1 0 1 0 + (+58)
1 0 1 1 0 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 1 Minuend
+ 1 0 0 1 1 1 Subtrahend
0 0 0 1 1 0 Difference
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 0 1 0 0 0 (+8)
+ 1 1 1 1 1 1 0 1 + (-3)
1 0 0 0 0 0 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 1 Multiplicand(11)
x 1 0 1 Multiplier(5)
1 0 1 1 Partial Product
0 0 0 0 Partial Product
1 0 1 1 Partial Product
1 1 0 1 1 1 Product(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)
1010 1 1 0 0 0 1 0 1 Divident(197)
1 0 1 0
0 1 0 0
0 0 0 0
1 0 0 1
0 0 0 0
1 0 0 1 0
1 0 1 0
1 0 0 0 1
1 0 1 0
1 1 1 Remainder(7)
Divisor(10)
Dr.S.Sivaranjani,AP-CSE
Binary Codes
( BCD, 8421 code,Gray code,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 (codes which obey the
positional weight principle.)
• 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 0 0 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 0 0 1 1 1 67
+ 0 1 0 1 0 0 1 1 + 53
1 0 1 1 1 0 1 0
0 1 1 0 0 1 1 0
0 0 0 1 0 0 1 0 0 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
1 0 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
1 2 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
Decimal Binary Gray
0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
2 0 0 1 0 0 0 1 1
3 0 0 1 1 0 0 1 0
4 0 1 0 0 0 1 1 0
5 0 1 0 1 0 1 1 1
6 0 1 1 0 0 1 0 1
7 0 1 1 1 0 1 0 0
8 1 0 0 0 1 1 0 0
9 1 0 0 1 1 1 0 1
10 1 0 1 0 1 1 1 1
11 1 0 1 1 1 1 1 0
12 1 1 0 0 1 0 1 0
12 1 1 0 1 1 0 1 1
14 1 1 1 0 1 0 0 1
15 1 1 1 1 1 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 1 0 0 0
6 0 1 1 0 1 0 0 1
7 0 1 1 1 1 0 1 0
8 1 0 0 0 1 0 1 1
9 1 0 0 1 1 1 0 0
10 0001 0000 0100 0011
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

More Related Content

Similar to Digital Design Digital Sytems Number Systems

IS 151 Lecture 1 (2015)
IS 151 Lecture 1 (2015)IS 151 Lecture 1 (2015)
IS 151 Lecture 1 (2015)
Aron Kondoro
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
PraveenThabbannavar
 
Number systems
Number systemsNumber systems
Number systems
ponandannel
 
Chap01 - Number Systems in Digital Logic.pptx
Chap01 - Number Systems in Digital Logic.pptxChap01 - Number Systems in Digital Logic.pptx
Chap01 - Number Systems in Digital Logic.pptx
Dr. Yasir Butt
 
Decimal, Binary, Octal, And Hexadecimal number systems.
Decimal, Binary, Octal, And Hexadecimal number systems.Decimal, Binary, Octal, And Hexadecimal number systems.
Decimal, Binary, Octal, And Hexadecimal number systems.
AOUN ABBAS
 
Data Analysis and Programming in R
Data Analysis and Programming in RData Analysis and Programming in R
Data Analysis and Programming in R
Eshwar Sai
 
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
Dr. Mazin Mohamed alkathiri
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Ra'Fat Al-Msie'deen
 
Course Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdfCourse Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdf
MdJubayerFaisalEmon
 
Linear regression by Kodebay
Linear regression by KodebayLinear regression by Kodebay
Linear regression by Kodebay
Kodebay
 
Lecture 1 PPT Number systems & conversions part.pptx
Lecture 1 PPT Number systems & conversions part.pptxLecture 1 PPT Number systems & conversions part.pptx
Lecture 1 PPT Number systems & conversions part.pptx
cronydeva
 
Data repersentation.
Data repersentation.Data repersentation.
Data repersentation.
Ritesh Saini
 
Boolean Algebra Arithmetic SIG UNSIGN.ppt
Boolean Algebra  Arithmetic SIG UNSIGN.pptBoolean Algebra  Arithmetic SIG UNSIGN.ppt
Boolean Algebra Arithmetic SIG UNSIGN.ppt
AshishChandrakar12
 
Digital Electronics & Fundamental of Microprocessor-I
Digital Electronics & Fundamental of Microprocessor-IDigital Electronics & Fundamental of Microprocessor-I
Digital Electronics & Fundamental of Microprocessor-I
pravinwj
 
NUMBER SYSTEM.pptx
NUMBER SYSTEM.pptxNUMBER SYSTEM.pptx
NUMBER SYSTEM.pptx
NathanielRapanut2
 
Acem numbersystem
Acem numbersystemAcem numbersystem
Acem numbersystem
Aastha Kohli
 
Binary computing
Binary computingBinary computing
Binary computing
samina khan
 
Lecture-2(2): Number System & Conversion
Lecture-2(2): Number System & ConversionLecture-2(2): Number System & Conversion
Lecture-2(2): Number System & Conversion
Mubashir Ali
 
DLD_Lecture_notes2.ppt
DLD_Lecture_notes2.pptDLD_Lecture_notes2.ppt
DLD_Lecture_notes2.ppt
NazmulHasan854383
 
DLD Chapter-1.pdf
DLD Chapter-1.pdfDLD Chapter-1.pdf
DLD Chapter-1.pdf
TamiratDejene1
 

Similar to Digital Design Digital Sytems Number Systems (20)

IS 151 Lecture 1 (2015)
IS 151 Lecture 1 (2015)IS 151 Lecture 1 (2015)
IS 151 Lecture 1 (2015)
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Number systems
Number systemsNumber systems
Number systems
 
Chap01 - Number Systems in Digital Logic.pptx
Chap01 - Number Systems in Digital Logic.pptxChap01 - Number Systems in Digital Logic.pptx
Chap01 - Number Systems in Digital Logic.pptx
 
Decimal, Binary, Octal, And Hexadecimal number systems.
Decimal, Binary, Octal, And Hexadecimal number systems.Decimal, Binary, Octal, And Hexadecimal number systems.
Decimal, Binary, Octal, And Hexadecimal number systems.
 
Data Analysis and Programming in R
Data Analysis and Programming in RData Analysis and Programming in R
Data Analysis and Programming in R
 
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 
Course Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdfCourse Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdf
 
Linear regression by Kodebay
Linear regression by KodebayLinear regression by Kodebay
Linear regression by Kodebay
 
Lecture 1 PPT Number systems & conversions part.pptx
Lecture 1 PPT Number systems & conversions part.pptxLecture 1 PPT Number systems & conversions part.pptx
Lecture 1 PPT Number systems & conversions part.pptx
 
Data repersentation.
Data repersentation.Data repersentation.
Data repersentation.
 
Boolean Algebra Arithmetic SIG UNSIGN.ppt
Boolean Algebra  Arithmetic SIG UNSIGN.pptBoolean Algebra  Arithmetic SIG UNSIGN.ppt
Boolean Algebra Arithmetic SIG UNSIGN.ppt
 
Digital Electronics & Fundamental of Microprocessor-I
Digital Electronics & Fundamental of Microprocessor-IDigital Electronics & Fundamental of Microprocessor-I
Digital Electronics & Fundamental of Microprocessor-I
 
NUMBER SYSTEM.pptx
NUMBER SYSTEM.pptxNUMBER SYSTEM.pptx
NUMBER SYSTEM.pptx
 
Acem numbersystem
Acem numbersystemAcem numbersystem
Acem numbersystem
 
Binary computing
Binary computingBinary computing
Binary computing
 
Lecture-2(2): Number System & Conversion
Lecture-2(2): Number System & ConversionLecture-2(2): Number System & Conversion
Lecture-2(2): Number System & Conversion
 
DLD_Lecture_notes2.ppt
DLD_Lecture_notes2.pptDLD_Lecture_notes2.ppt
DLD_Lecture_notes2.ppt
 
DLD Chapter-1.pdf
DLD Chapter-1.pdfDLD Chapter-1.pdf
DLD Chapter-1.pdf
 

Recently uploaded

原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理 原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
tzu5xla
 
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Kaxil Naik
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
xclpvhuk
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
TeukuEriSyahputra
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
SaffaIbrahim1
 
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
mkkikqvo
 
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
slg6lamcq
 
Jio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdfJio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdf
inaya7568
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
writing report business partner b1+ .pdf
writing report business partner b1+ .pdfwriting report business partner b1+ .pdf
writing report business partner b1+ .pdf
VyNguyen709676
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
ywqeos
 
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
nyvan3
 
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
asyed10
 
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
oaxefes
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
1tyxnjpia
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 

Recently uploaded (20)

原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理 原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
 
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
 
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
原版一比一多伦多大学毕业证(UofT毕业证书)如何办理
 
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
 
Jio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdfJio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdf
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
writing report business partner b1+ .pdf
writing report business partner b1+ .pdfwriting report business partner b1+ .pdf
writing report business partner b1+ .pdf
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
 
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
 
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
一比一原版美国帕森斯设计学院毕业证(parsons毕业证书)如何办理
 
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 

Digital Design Digital Sytems Number Systems

  • 2. Course Topics(Unit –I) • Introduction to Digital Systems • Number systems • Number-Base conversion • Complements of Numbers (Diminished Radix complement ,Radix Complement) • Signed Binary Numbers • Arithmetic operation with the Binary Numbers • Binary Codes ( BCD, 8421 code,Gray code,ASCII) Dr.S.Sivaranjani,AP-CSE
  • 3. • Digital Systems are part of your daily activities. • Everything in Digital(High Resolution Display) : Camera, Laptop, Mobile phones, Tab- we are using Digital Electronics Dr.S.Sivaranjani,AP-CSE Data processing Data transmission Device control Digital Systems Made or build using Introduction to Digital Systems
  • 4. • Digital Devices have GUI [ Graphical User Interface] • Enable the devices to execute commands that appear to the user to be simple but which involves precise execution of a sequence of complex internal instructions • Digital Systems are fast, accurate and consume less power. Dr.S.Sivaranjani,AP-CSE
  • 5. Digital Systems • Stemming from word “Digit” [means 0,1,2,3…] • Use digital signals or information to operate • Digital Signals : are discrete signals that represent information in the form of binary digits (bits) which can take only one of two values (0&1) Dr.S.Sivaranjani,AP-CSE
  • 7. 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 [storage devices are used to store data and instructions, such as memory chips and hard drives]
  • 8. 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
  • 9. • A digital system is a system that processes information in a digital form. • It consists of electronic devices that manipulate digital signals, such as binary code, using a set of logic gates and algorithms. • These devices include microprocessors, microcontrollers, digital signal processors, and other digital integrated circuits. Dr.S.Sivaranjani,AP-CSE
  • 10. Applications of digital system Digital systems have a wide range of applications in various fields, including: Communication systems: • Digital systems are used in communication systems, such as cellular phones, satellites, and the internet. • They enable reliable transmission and reception of data and voice signals over long distances. Control systems: • Digital systems are used in control systems, such as robotics, process control, and automotive control systems. • They allow for precise control of devices and processes, ensuring optimal performance. Digital signal processing: • Digital systems are used in digital signal processing applications, such as audio and video processing, image and speech recognition, and radar and sonar systems. Dr.S.Sivaranjani,AP-CSE
  • 11. Medical devices: • Digital systems are used in medical devices, such as pacemakers, MRI machines, and digital X-ray machines. • They enable accurate and reliable diagnostic and treatment procedures. Consumer electronics: • Digital systems are used in consumer electronics, such as smartphones, tablets, laptops, and smart TVs. • They provide a wide range of functions and capabilities, such as multimedia playback, internet access, and gaming. Dr.S.Sivaranjani,AP-CSE
  • 12. Industrial automation: • Digital systems are used in industrial automation systems, such as manufacturing plants, assembly lines, and logistics systems. • They enable efficient and automated control of production and logistics processes. Defense and aerospace: • Digital systems are used in defense and aerospace applications, such as military communication systems, guidance and control systems for aircraft and missiles, and satellite communication and navigation systems. Dr.S.Sivaranjani,AP-CSE
  • 14. General Representation • A number is represented as a5a4a3a2a1a0.a-1a-2a-3a-4 • . - radix point • aj – coefficients(symbols used in a number representation) • j – place value • Example: – Decimal number: 567.28 Dr.S.Sivaranjani,AP-CSE
  • 15. Radix or Base • The radix of a number system is also known as its base or its numerical base. • It refers to the number of unique digits or symbols used in the system to represent numbers. • For example, the decimal system that we use in everyday life has a radix of 10 because it uses 10 digits (0-9) to represent numbers. Dr.S.Sivaranjani,AP-CSE
  • 16. • The radix of a number system is an integer greater than 1. • The value of the radix determines the range of values that can be represented using the system, as well as the way in which numbers are written and manipulated. • For example, in a binary system with a radix of 2, there are only two possible digits (0 and 1), which means that all numbers are represented using only these two digits. • Different number systems are used in different contexts, and each system has its own radix. Dr.S.Sivaranjani,AP-CSE
  • 17. Common number systems and their radices • Binary system (radix 2): Uses two digits (0 and 1) to represent numbers. • Octal system (radix 8): Uses eight digits (0-7) to represent numbers. • Decimal system (radix 10): Uses ten digits (0-9) to represent numbers. • Hexadecimal system (radix 16): Uses sixteen digits (0-9 and A-F) to represent numbers. Understanding the radix of a number system is important for converting between different systems and for understanding how computers represent and manipulate numbers. Dr.S.Sivaranjani,AP-CSE
  • 18. Radix or Base • In a positional numeral system(value of each symbol depends on the position), the radix or base is the number of unique digits, 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
  • 19. Positional Number System • Another representation of a number: anrn+an-1rn-1+…+a1r1+a0r0+a-1r-1+a-2r-2+…+a-mr-m • aj – coefficients • j – place value/ positional value • r – radix or base • Eg: 567.28(decimal number) – 567.28 = 5x102+6x101+7x100+2x10-1+8x10-2 Dr.S.Sivaranjani,AP-CSE
  • 20. Radix - 2 (Binary Numbers) • Symbols Used: 0,1 • Base: 2 Dr.S.Sivaranjani,AP-CSE
  • 21. Radix - 8 (Octal Numbers) • Symbols Used: 0,1,2,3,4,5,6,7 • Base: 8 Dr.S.Sivaranjani,AP-CSE
  • 22. Radix – 10 (Decimal Numbers ) • Symbols Used: 0,1,2,3,4,5,6,7,8,9 • Base: 10 Dr.S.Sivaranjani,AP-CSE
  • 23. 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
  • 24. Example • The number “twenty-seven” can be represented in different ways : – IIIII IIIII IIIII IIIII IIIII II (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
  • 25. 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 11th 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
  • 26. 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
  • 27. Conversion between Number Systems (Binary to decimal number) • 100.111 (100.111)2=1x22+0x21+0x20+1x2-1+1x2-2+1x2-3 = 4+0+0+0.5+0.25+0.125 = (4.875)10 Dr.S.Sivaranjani,AP-CSE
  • 28. 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
  • 29. Conversion between Number Systems (Octal to decimal number) • 517.35 (517.35)8=5x82+1x81+7x80+3x8-1+5x8-2 = 320+8+7+0.375+0.078125 = (335.453125)10 Dr.S.Sivaranjani,AP-CSE
  • 30. Conversion between Number Systems (Hexadecimal to decimal number) • 786.BC (786.BC)16=7x162+8x161+6x160+Bx16-1+Cx16-2 = 1792+128+6+0.6875+0.046875 = (1926.734375)10 Dr.S.Sivaranjani,AP-CSE
  • 31. 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
  • 32. Conversion between Number Systems (decimal to binary number) • 343.392 (343)10 = (101010111)2 0.392 x 2 = 0 .784 0.784 x 2 = 1 .568 0.568 x 2 = 1 .136 0.136 x 2 = 0 .272 0.272 x 2 = 0 .544 0.544 x 2 = 1 .088 2 343 2 171 - 1 2 85 - 1 2 42 - 1 2 21 - 0 2 10 - 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
  • 33. Conversion between Number Systems (decimal to octal number) • 153.513 (153)10 = (231)8 0.513 x 8 = 4 .104 0.104 x 8 = 0 .832 0.832 x 8 = 6 .656 0.656 x 8 = 5 .248 0.248 x 8 = 1 .984 0.984 x 8 = 7 .872 8 153 8 19 - 1 2 - 3 (0.513)10 = (0.406517…)8 Ans: (153.513)10 = (231.406517)8 Dr.S.Sivaranjani,AP-CSE
  • 34. Conversion between Number Systems (decimal to hexadecimal number) • 487.365 (487)10 = (1E7)16 0.365 x 16 = 5 .84 0.84 x 16 = 13 .44 0.44 x 16 = 7 .04 0.04 x 16 = 0 .64 0.64 x 16 = 10 .24 0.24 x 16 = 3 .84 16 487 16 30 - 7 1 - E (0.365)10 = (0.5D70A3…)16 Ans: (487.365)10 = (1E7.5D70A3)16 Dr.S.Sivaranjani,AP-CSE
  • 35. 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
  • 36. 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
  • 37. 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
  • 38. 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
  • 39. 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
  • 40. 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
  • 42. Dr.S.Sivaranjani,AP-CSE Complements of Numbers (Diminished Radix complement ,Radix Complement)
  • 43. Complement • There are two types of complements for each base-r number system: – Radix complement (or) r’s complement – Diminished radix complement (or) (r-1)’s complement • Complements are used in digital computers for simplifying the subtraction operation. Dr.S.Sivaranjani,AP-CSE
  • 44. r-1’s Complement/ Diminished Radix Complement • The (r-1)’s complement of N: (rn-1)-N  N – Number  r – radix /base  n – number of digits in N  (rn-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
  • 45. 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 = (27-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
  • 46. 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
  • 47. 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 = (83-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
  • 48. 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 = (106-1)10 – (546700)10 = (1000000-1)10 – (546700)10 = (999999)10 – (546700)10 = 453299 Largest 6 digit decimal number Dr.S.Sivaranjani,AP-CSE
  • 49. r-1’s Complement of Hexdecimal Number/ 15’s Complement • N = C3DF ; r= 16 n= 4; r-1 = 15 (15’s complement) 15’s complement = (164-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
  • 50. r’s Complement/Radix Complement • The r’s complement of N: rn-N for N ≠ 0 0 for N = 0  N – Number  r – radix /base  n – number of digits in N • r’s complement is obtained by adding 1 to (r-1)’s complement: rn-N = [(rn-1)-N]+1 • Note: It is better to do (r-1)’s complement first for r’s complement since it is easy to do the subtraction in (r-1)’s complement(no borrow problem!). Dr.S.Sivaranjani,AP-CSE
  • 51. r’s Complement 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
  • 52. 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 1st ‘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 1st ‘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
  • 53. r’s Complement 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
  • 54. r’s Complement 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
  • 55. r’s Complement 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
  • 56. 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
  • 57. 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
  • 58. 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
  • 59. 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
  • 60. 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
  • 61. Subtraction with Complements r’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’s complement of the subtrahend N. This performs: M+(rn-N)=M-N+rn – If M≥ N, the sum will produce an end carry,rn, 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 rn-(N-M), which is the r’s complement of N-M Dr.S.Sivaranjani,AP-CSE
  • 62. r’s Complement 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 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 0 1 1 0 0 0 0 1 1 0 1 0 1 1 0 0 1 1 0 1 1 1 1 Dr.S.Sivaranjani,AP-CSE
  • 63. r’s Complement 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 1 2 5 2 Dr.S.Sivaranjani,AP-CSE
  • 64. r’s Complement 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 1 6 9 2 8 2 0 3 2 5 0 2 7 4 6 8 3 0 7 1 8 Dr.S.Sivaranjani,AP-CSE
  • 65. r’s Complement 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 1 6 4 0 6 7 2 3 4 E 9 C 0 Dr.S.Sivaranjani,AP-CSE
  • 66. 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’s complement 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,which is the r-1’s complement of N-M Dr.S.Sivaranjani,AP-CSE
  • 67. 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 1 0 1 1 1 0 1 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 Dr.S.Sivaranjani,AP-CSE
  • 68. 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 1 4 3 7 5 7 1 1 4 0 2 4 6 3 1 0 6 5 1 0 6 6 Dr.S.Sivaranjani,AP-CSE
  • 69. 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 1 3 3 3 2 1 3 3 3 3 Dr.S.Sivaranjani,AP-CSE
  • 70. 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 1 1 7 5 1 1 7 6 Dr.S.Sivaranjani,AP-CSE
  • 72. 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
  • 73. 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
  • 74. 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
  • 75. 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
  • 76. 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
  • 77. 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
  • 78. 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: 0x26+0x25+1x24+0x23+1x22+0x21+1x20 = 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
  • 79. 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: -0x27+0x26+0x25+1x24+0x23+1x22+1x21+1x20 = 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: -1x27+1x26+1x25+0x24+1x23+0x22+0x21+0x20 = -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 representation Dr.S.Sivaranjani,AP-CSE
  • 80. 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: -0x27+1x26+0x25+1x24+0x23+1x22+1x21+0x20 = 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: -1x27+0x26+1x25+0x24+1x23+0x22+1x21+0x20 = -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
  • 81. 3-bit representation of signed numbers No Possible 3-bit represent ations If only positive numbers represented If negative numbers also should be represented (sign- magnitude) If negative numbers also should be represented (1’s complement) If negative numbers also should be represented (2’s complement) 1 000 0 +0 +0 0 2 001 1 +1 +1 +1 3 010 2 +2 +2 +2 4 011 3 +3 +3 +3 5 100 4 -0 -3 -4 6 101 5 -1 -2 -3 7 110 6 -2 -1 -2 8 111 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
  • 82. Arithmetic operation with the Binary Numbers Dr.S.Sivaranjani,AP-CSE
  • 83. 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 0 0 1 1 1 Augend + 0 0 0 0 0 1 0 0 Addend 0 0 0 0 1 0 1 1 Sum Dr.S.Sivaranjani,AP-CSE
  • 84. Binary Addition • Both numbers are positive (consider 8 bit) • Positive number with magnitude larger than negative number 0 0 0 0 0 1 1 1 (+7) + 0 0 0 0 0 1 0 0 + (+4) 0 0 0 0 1 0 1 1 11 0 0 0 0 1 1 1 1 (+15) + 1 1 1 1 1 0 1 0 + (-6) 1 0 0 0 0 1 0 0 1 9 Discard Carry Dr.S.Sivaranjani,AP-CSE
  • 85. Binary Addition • Negative number with magnitude larger than positive number • Both numbers are negative 0 0 0 1 0 0 0 0 (+16) + 1 1 1 0 1 0 0 0 + (-24) 1 1 1 1 1 0 0 0 -8 1 1 1 1 1 0 1 1 (-5) + 1 1 1 1 0 1 1 1 + (-9) 1 1 1 1 1 0 0 1 0 -14 Discard Carry Dr.S.Sivaranjani,AP-CSE
  • 86. 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 1 1 1 0 1 (+125) + 0 0 1 1 1 0 1 0 + (+58) 1 0 1 1 0 1 1 1 183 Incorrect Sign bit Dr.S.Sivaranjani,AP-CSE
  • 87. 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 1 Minuend + 1 0 0 1 1 1 Subtrahend 0 0 0 1 1 0 Difference Dr.S.Sivaranjani,AP-CSE
  • 88. 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
  • 89. Binary Subtraction • 00001000-00000011 – 2’s complement of 00000011=11111101 0 0 0 0 1 0 0 0 (+8) + 1 1 1 1 1 1 0 1 + (-3) 1 0 0 0 0 0 1 0 1 +5 Dr.S.Sivaranjani,AP-CSE
  • 90. Binary Multiplication • Multiplication – The numbers in multiplication: • Multiplicand • Multiplier – Result is: • Product • (Partial Product) Dr.S.Sivaranjani,AP-CSE
  • 91. Binary Multiplication • 1011 x 101 1 0 1 1 Multiplicand(11) x 1 0 1 Multiplier(5) 1 0 1 1 Partial Product 0 0 0 0 Partial Product 1 0 1 1 Partial Product 1 1 0 1 1 1 Product(55) Dr.S.Sivaranjani,AP-CSE
  • 92. Binary Division • Division – The numbers in division: • Dividend • Divisor – Result is: • Quotient • Remainder Dr.S.Sivaranjani,AP-CSE
  • 93. Binary Division • 11000101 ÷ 1010 1 0 0 1 1 Quotient(19) 1010 1 1 0 0 0 1 0 1 Divident(197) 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 0 1 1 1 Remainder(7) Divisor(10) Dr.S.Sivaranjani,AP-CSE
  • 94. Binary Codes ( BCD, 8421 code,Gray code,ASCII) Dr.S.Sivaranjani,AP-CSE
  • 95. 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
  • 96. Binary Coded Decimal(BCD)/8421 • Straight binary assignment of the decimal numbers. • It is a weighted code (codes which obey the positional weight principle.) • 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
  • 97. 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 0 0 0 1 0 0 0 0 Dr.S.Sivaranjani,AP-CSE
  • 98. 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
  • 99. BCD Addition • 0110 0111 + 0101 0011 0 1 1 0 0 1 1 1 67 + 0 1 0 1 0 0 1 1 + 53 1 0 1 1 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 120 Invalid BCD Invalid BCD Dr.S.Sivaranjani,AP-CSE
  • 100. 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
  • 101. 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 1 0 1 3 5 Discard Carry Sign Dr.S.Sivaranjani,AP-CSE
  • 102. 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
  • 103. 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 1 2 9 1 3 0 Carry Carry generated added to result Dr.S.Sivaranjani,AP-CSE
  • 104. Gray Code • Un-weighted code • Important Feature: – It exhibits one a single bit change from one code word to the next in sequence Decimal Binary Gray 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 2 0 0 1 0 0 0 1 1 3 0 0 1 1 0 0 1 0 4 0 1 0 0 0 1 1 0 5 0 1 0 1 0 1 1 1 6 0 1 1 0 0 1 0 1 7 0 1 1 1 0 1 0 0 8 1 0 0 0 1 1 0 0 9 1 0 0 1 1 1 0 1 10 1 0 1 0 1 1 1 1 11 1 0 1 1 1 1 1 0 12 1 1 0 0 1 0 1 0 12 1 1 0 1 1 0 1 1 14 1 1 1 0 1 0 0 1 15 1 1 1 1 1 0 0 0 Dr.S.Sivaranjani,AP-CSE
  • 105. 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
  • 106. 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
  • 107. 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
  • 108. 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
  • 109. 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 1 0 0 0 6 0 1 1 0 1 0 0 1 7 0 1 1 1 1 0 1 0 8 1 0 0 0 1 0 1 1 9 1 0 0 1 1 1 0 0 10 0001 0000 0100 0011 Dr.S.Sivaranjani,AP-CSE
  • 110. 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
  • 111. 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
  • 112. 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
  • 113. 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
  • 114. 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
  • 115. 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