Course Teacher :
Colonel S M Saiful Islam, SUP, psc
CSE (BUET), MBA (IBA), MDS
ITIL® (Expert), Prince2® (Practitioner), CDCP®, ISO 27001 Lead Auditor®
Course Title :
CSE-1201: Digital Logic Design
Credit Hour: 3.0
Department of Computer Science & Engineering
Bangladesh University of Professionals
Chapter 01
BINARY SYSTEMS
2
Chapter 01: Binary Systems
Learning Objective
▪ Learn various binary systems that are suitable for representing
information in digital components.
▪ Understand the binary number system and how it functions.
▪ Explore binary codes and their use in representing decimal and
alphanumeric information.
▪ Gain an initial understanding of binary logic from an intuitive
perspective.
10-Nov-24
3
Chapter 01: Binary Systems
Overview
1. Digital Systems
2. Binary Numbers
3. Number Base Conversions
4. Octal and Hexadecimal Numbers
5. Complements
6. Signed Binary Numbers
7. Binary Codes
10-Nov-24
Topic- 1: Introduction to Number Systems and
Digital Components (Binary, Octal,
Hexadecimal Systems)​
10-Nov-24 Chapter 01: Binary Systems 4
5
Chapter 01: Binary Systems
Analog Vs Digital System
10-Nov-24
Analog System
• The physical quantities or signals may
vary continuously over a specified range
Digital System
• The physical quantities or signals can
assume only discrete values
• Greater accuracy
Analog Signal
Digital Signal
6
Chapter 01: Binary Systems
Digital Systems
10-Nov-24
• Digital systems are designed to store, process, and communicate
information in digital form.
• They are found in a wide range of applications, including process control,
communication systems, digital instruments, and consumer products. The
digital computer, more commonly called the computer, is an example of a
typical digital system.
• They are involved in our business transactions, communications,
transportation, medical treatment and entertainment. In industrial world
they are heavily employed in design, manufacturing, distribution and
sales.
7
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
• Takes a set of discrete
information inputs and
discrete internal information
(system state) and generates
a set of discrete information
outputs
Discrete
Information
Processing
System
System
State
Discrete
Inputs
Discrete
Outputs
8
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
Discrete
Information
Processing
System
System
State
Discrete
Inputs
Discrete
Outputs
• No state present
• Combinational Logic System
• Output = Function (Input)
• State present
• State updated at discrete times
• Synchronous Sequential System
• State updated at any time
• Asynchronous Sequential System
• State = Function (State, Input)
• Output = Function (State)
or Function (State, Input)
9
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
A Digital Counter (e. g., odometer):
Synchronous or Asynchronous?
1 3
0 0 5 6 4
Count Up
Reset
Inputs: Count Up, Reset
Outputs: Visual Display
State: "Value" of stored digits
10
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
Synchronous or Asynchronous?
Inputs: Keyboard, mouse,
modem, microphone
Outputs: CRT, LCD,
modem, speakers
Memory
Control
unit Datapath
Input/Output
CPU
11
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
Synchronous or Asynchronous?
• An information variable represented by physical quantity.
• For digital systems, the variable takes on discrete values.
• Two level, or binary values are the most prevalent values in digital
systems.
• Binary values are represented abstractly by:
• digits 0 and 1
• words (symbols) False (F) and True (T)
• words (symbols) Low (L) and High (H)
• and words On and Off.
• Binary values are represented by values or ranges of values of physical
quantities
12
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
Analog
Asynchronous
Synchronous
Time
Continuous in value
& time
Discrete in value &
continuous in time
Discrete in value &
time
Digital
Signal
13
Chapter 01: Binary Systems
Digital Systems (contd…)
10-Nov-24
Binary Digital Signal
• An information variable represented by physical quantity.
• For digital systems, the variable takes on discrete values.
• Two level, or binary values are the most prevalent values
• Binary values are abstractly represented by:
• Digits 0 and 1
• Words (symbols) False (F) and True (T)
• Words (symbols) Low (L) and High (H)
• And words On and Off
• Binary values are represented by values
or ranges of values of physical quantities
Binary Digital Signal
14
Chapter 01: Binary Systems
Number Systems
10-Nov-24
• Integers are normally written using positional number system, in
which each digit represents the coefficient in a power series
N = 𝑎𝑛−1 𝑟𝑛
− 1 + 𝑎𝑛−2 𝑟𝑛
− 2 + ⋯ + 𝑎2 𝑟2
+ 𝑎1 𝑟1
+ 𝑎0
Where,
n is the number of digit
r is the radix or base
𝑎𝑖 is the coefficient 0 ≤ 𝑎𝑖 ≤ r
• There are four systems of arithmetic which are often used in digital circuit
15
Chapter 01: Binary Systems
Number Systems
10-Nov-24
N = 𝑎𝑛−1 𝑟𝑛
− 1 + 𝑎𝑛−2 𝑟𝑛
− 2 + ⋯ + 𝑎2 𝑟2
+ 𝑎1 𝑟1
+ 𝑎0
0 ≤ 𝑎𝑖 ≤ r
2073 = 2 𝑥 103 + 0 𝑥102 + 7𝑥101 + 3
233 = 2 𝑥 82 + 3𝑥81 + 3
2A9 = 2 𝑥 162 + 𝐴𝑥161 + 9
16
Chapter 01: Binary Systems
Number Systems (contd…)
10-Nov-24
• Decimal: it has a base (r = 10) and coefficients (a) are in the range 0 to 9
• Binary: it has a base (r = 2) and coefficients (a) are all either 0 or 1
• Octal: it has a base (r = 8) and coefficients (a) are in the range 0 to 7
• Hexadecimal: it has a base (r = 16) and coefficients (a) are in the range
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
17
Chapter 01: Binary Systems
Number Systems (contd…)
10-Nov-24
General Decimal Binary
Radix (Base) r 10 2
Digits 0 => r - 1 0 => 9 0 => 1
0
1
2
3
Powers of 4
Radix 5
-1
-2
-3
-4
-5
r0
r1
r2
r3
r4
r5
r -1
r -2
r -3
r -4
r -5
1
10
100
1000
10,000
100,000
0.1
0.01
0.001
0.0001
0.00001
1
2
4
8
16
32
0.5
0.25
0.125
0.0625
0.03125
18
Chapter 01: Binary Systems
Number Systems (contd…)
10-Nov-24
Commonly Occurring Bases
Name Radix Digits
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
19
Chapter 01: Binary Systems
Number Systems (contd…)
10-Nov-24
Decimal
(Base 10)
Binary
(Base 2)
Octal
(Base 8)
Hexadecimal
(Base 16)
00 00000 00 00
01 00001 01 01
02 00010 02 02
03 00011 03 03
04 00100 04 04
05 00101 05 05
06 00110 06 06
07 00111 07 07
08 01000 10 08
09 01001 11 09
10 01010 12 0A
11 01011 13 0B
12 01100 14 0C
13 01101 15 0D
14 01110 16 0E
15 01111 17 0F
16 10000 20 10
20
Chapter 01: Binary Systems
Number Systems (contd…)
10-Nov-24
210 (1024) is Kilo, denoted "K"
220 (1,048,576) is Mega, denoted "M"
230 is Giga, denoted "G"
Exponent Value Exponent Value
0 1 11 2,048
1 2 12 4,096
2 4 13 8,192
3 8 14 16,384
4 16 15 32,768
5 32 16 65,536
6 64 17 131,072
7 128 18 262,144
19 524,288
20 1,048,576
21 2,097,152
8 256
9 512
10 1024
240 is Tera, denoted "G"
250 is Peta, denoted “P"
21
Chapter 01: Binary Systems
Number Systems (contd…)
10-Nov-24
(73925)10 = 7*104 + 3*103 + 9*102 + 2*101 + 5*100
(a4 a3 a2 a1 a0)10 = a4 *104 + a3*103 + a2*102 + a1 *101 + a0*100
(a4 a3 a2 a1 a0)r = a4 *r4 + a3*r3 + a2*r2 + a1 *r1 + a0*r0
(an an-1 ………a2 a1 a0)r = an *rn + an-1*rn-1 + …… + a2*r2 + a1 *r1 + a0*r0
(73925.613)10 = 7*104 + 3*103 + 9*102 + 2*101 + 5*100 + 6*10-1 + 1*10-2 + 3*10-3
(an an-1 ………a2 a1 a0.a-1 a-2 ......a-m)r
= an *rn + an-1*rn-1 + …… + a2*r2 + a1 *r1 + a0*r0 + a-1*r-1 + a-2 *r-2 + ………… +
a-m*r-m
22
Chapter 01: Binary Systems
Binary Arithmetic
10-Nov-24
• Binary arithmetic is essential in all digital computers and in many other
types of digital systems.
• To understand digital systems, one must know the basics of
• Binary Addition
• Binary Subtraction
• Binary Multiplication
• Binary Division
23
Chapter 01: Binary Systems
Binary Arithmetic (contd…)
10-Nov-24
Binary Addition
Carry
24
Chapter 01: Binary Systems
Binary Arithmetic (contd…)
10-Nov-24
Binary Subtraction
Borrow a “Base” when needed
25
Chapter 01: Binary Systems
Binary Arithmetic (contd…)
10-Nov-24
Binary Multiplication
Bit by Bit
26
Chapter 01: Binary Systems
Binary Arithmetic (contd…)
10-Nov-24
Binary Division
101 110111
-101
111
-101
0101
-101
0
1011
Division in binary follows the same procedure as division in decimal.
27
Chapter 01: Binary Systems
Exercise
10-Nov-24
• Perform the following binary additions:
a) 1101 + 1010
b) 10111 + 01101
• Perform the following binary subtractions:
a) 1101 – 0100
b) 1001 – 0111
• Perform the indicated binary operations:
a) 110 × 111
b) 1100 ÷ 011
Topic- 2: Conversions Between Number
Systems, Complements and Codes​
10-Nov-24 Chapter 01: Binary Systems 28
29
Chapter 01: Binary Systems
Conversion Between Bases
10-Nov-24
1) Convert the Integer Part:
Repeatedly divide the number by the new radix and save the remainders. The digits for
the new radix are the remainders in reverse order of their computation. If the new radix is
> 10, then convert all remainders > 10 to digits A, B, …
2) Convert the Fractional Part:
Repeatedly multiply the fraction by the new radix and save the integer digits that result.
The digits for the new radix are the integer digits in order of their computation. If the new
radix is > 10, then convert all integers > 10 to digits A, B, …
3) Join the two results with a radix point
30
Chapter 01: Binary Systems
Conversion Between Bases (Binary-to-Decimal)
10-Nov-24
(a) Integer (b) Fraction
110102 =1*24 + 1*23 + 0*22 + 1*21 + 0*20
= 16 + 8 + 0 + 2 + 0
= (26)10
1011102 = 1*25 + 0*24 + 1*23 + 1*22 + 1*21+ 0*20
= 32 + 8 + 4 + 2
= (46)10
31
Chapter 01: Binary Systems
10-Nov-24
(a) Integer (b) Fraction
25 ÷ 2 = 12 +1
12 ÷ 2 = 6 +0
6 ÷ 2 = 3 +0
3 ÷ 2 = 1 +1
1 ÷ 2 = 0 +1
2510 = 110012
0.625 × 2 = 1.25 = 0.25 + 1
0.25 × 2 = 0.5 = 0.5 + 0
0.5 × 2 = 1.0 = 0.0 + 1
0.62510 = 0.1012
Conversion Between Bases (Decimal-to-Binary)
32
Chapter 01: Binary Systems
Conversion Between Bases (Decimal-to-Octal)
10-Nov-24
(a) Integer (b) Fraction
3928610 = 1145668 0.34210 = 0.25708
33
Chapter 01: Binary Systems
10-Nov-24
(a) Integer (b) Fraction
1408 = 9610
1725.438 = 981.54687510
Conversion Between Bases (Octal-to-Decimal)
34
Chapter 01: Binary Systems
10-Nov-24
(a) Integer (b) Fraction
Conversion Between Bases (Decimal-to-Hexadecimal)
35
Chapter 01: Binary Systems
10-Nov-24
(a) Integer (b) Fraction
54.D216 = 84.820312510
Conversion Between Bases (Hexadecimal-to-Decimal)
36
Chapter 01: Binary Systems
10-Nov-24
Works both ways (Binary to Octal & Octal to Binary)
10110.012 = 26.28
Conversion Between Bases (Binary to/from Octal)
37
Chapter 01: Binary Systems
10-Nov-24
10110.012 = 16.416
Conversion Between Bases (Binary to/from Hexadecimal)
38
Chapter 01: Binary Systems
10-Nov-24
26.28 = 16.416
Conversion Between Bases (Octal to/from Hexadecimal)
39
Chapter 01: Binary Systems
10-Nov-24
Conversion of Binary to Octal & Hexadecimal
(10110001101011 . 111100000110)2 = (26153.7406)8
0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 . 1 1 1 1 0 0 0 0 0 1 1 0
2 6 1 5 3 . 7 4 0 6
(10110001101011 . 111100000110)2 = (2C6B.F06)16
0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 . 1 1 1 1 0 0 0 0 0 1 1 0
2 C 6 B F 0 6
Conversion Between Bases (Binary to/from Hexadecimal)
40
Chapter 01: Binary Systems
10-Nov-24
Conversion of Hexadecimal-to-Binary-to-Octal
Hexa 2 C 6 B F 0 6
Binary 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 . 1 1 1 1 0 0 0 0 0 1 1 0
Octal 2 6 1 5 3 7 4 0 6
(2C6B.F06)16 = (26153.7406)8
Conversion Between Bases (Binary to/from Hexadecimal)
41
Chapter 01: Binary Systems
Exercise
10-Nov-24
• Convert the decimal number 250.5 to base 3, base 4, base 7, base 8,
and base 16.
• Convert the following decimal numbers to binary: 12.0625, 104, 673.23,
and 1998.
• Convert the following binary numbers to decimal: 10.10001, 101110.0101,
1110101.0101, 1110101.110.
• Convert the following numbers from the given base to the bases indicated:
a) Decimal 225.225 to binary, octal, and hexadecimal
b) Binary 11010111.110 to decimal, octal, and hexadecimal
c) Octal 623.77 to decimal, binary, and hexadecimal
d) Hexadecimal 2AC5.D to decimal, octal, and binary
42
Chapter 01: Binary Systems
Complements
10-Nov-24
• Complements are used in digital computers for simplifying the subtraction
operation and for logical manipulations.
• There are two types of complements for each base-r system:
• r’s complement
• (r-1)’s complement
43
Chapter 01: Binary Systems
Complements
10-Nov-24
r's complement of (N)r = rn - N
• 10's of (52520)10 = 105 – 52520 = 47480
• 10's of (0.3267)10 = 1 - 0.3267 = 0.6733
• 10's of (25.639)10 = 102 - 25.639 = 74.631
• 2's of (101100)2 = 26 – 101100
= 100000 – 101100
= (010100)2
• 2's of (0.0110)2 = 1 - 0.0110
= 0.1010
44
Chapter 01: Binary Systems
Complements
10-Nov-24
(r-1)'s complement of (N)r = rn -1- N
rn -1 = (r-1) (r-1) ……… (r-1) (r-1) (r-1) ….. up to n i.e. 105 -1 = 99999 ( five digits of 9)
• 9's of (52520)10 = 99999 – 52520 = 47479
• 9's of (0.3267)10 = 0.9999 - 0.3267 = 0.6732
• 9's of (25.639)10 = 99.999 - 25.639 = 74.630
• 1's of (101100)2 = 111111 – 101100
= (010011)2
• 1's of (0.0110)2 = 0.1111 - 0.0110
= 0.1001
45
Chapter 01: Binary Systems
Subtraction with Complements
10-Nov-24
Subtraction with r's complement
• Make the minuend and subtrahend equal in digits
• Add the minuend to the r's complement of the subtrahend
• If and end-carry occurs, ignore it
• If there is no end carry, make the r's complement of the result and place a
negative sign in front.
46
Chapter 01: Binary Systems
Subtraction with 10's complement
10-Nov-24
Example : Subtract 72532 - 3250
Minuend M = 7 2 5 3 2 M = 7 2 5 3 2 M = 7 2 5 3 2
Subtrahend N = 3 2 5 0 N = 0 3 2 5 0 10's complement of N = + 9 6 7 5 0
end carry 1 6 9 2 8 2
Answer = 69282
Example : Subtract 3250 - 72532
Minuend M = 3 2 5 0 M = 0 3 2 5 0 M = 0 3 2 5 0
Subtrahend N = 7 2 5 3 2 N = 7 2 5 3 2 10's complement of N = + 2 7 4 6 8
end carry 0 3 0 7 1 8
10's complement of 30718 = 69282
Answer = ‒ 69282
47
Chapter 01: Binary Systems
Subtraction with 2's complement
10-Nov-24
Example : Subtract 1010100 – 1000100
Minuend M = 1010100 M = 1010100
Subtrahend N = 1000100 2’s complement of N = + 0111100
end carry 1 0010000
Answer = 10000
Example : Subtract 1000100 – 1010100
Minuend M = 1000100 M = 1000100
Subtrahend N = 1010100 2’s complement of N = + 0101100
end carry 0 1110000
2’s complement of 1110000 = 10000
Answer = - 10000
48
Chapter 01: Binary Systems
Subtraction with (r-1)'s complement
10-Nov-24
• Make the minuend and subtrahend equal in digits
• Add the minuend to the (r-1)'s complement of the subtrahend
• If and end-carry occurs, add 1 with the result
• If there is no end carry, make the (r-1)'s complement of the result and
place a negative sign in front.
49
Chapter 01: Binary Systems
Subtraction with 9's complement
10-Nov-24
Example: Subtract 3250 - 72532
Minuend M = 3 2 5 0 M = 0 3 2 5 0 M = 0 3 2 5 0
Subtrahend N = 7 2 5 3 2 N = 7 2 5 3 2 9’s complement of N = + 2 7 4 6 7
end carry 0 3 0 7 1 7
9’s complement of 30717 = 69282
Answer = - 69282
Example : Subtract 72532 - 3250
Minuend M = 7 2 5 3 2 M = 7 2 5 3 2 M = 7 2 5 3 2
Subtrahend N = 3 2 5 0 N = 0 3 2 5 0 9’s complement of N = + 9 6 7 4 9
end carry 1 6 9 2 8 1
+ 1
6 9 2 8 2
Answer = 69282
50
Chapter 01: Binary Systems
Subtraction with 1's complement
10-Nov-24
Example : Subtract 1010100 – 1000100
Minuend M = 1010100 M = 1010100
Subtrahend N = 1000100 1’s complement of N = + 0111011
end carry 1 0001111
+ 1
0010000
Answer = 10000
Example : Subtract 1000100 – 1010100
Minuend M = 1000100 M = 1000100
Subtrahend N = 1010100 1’s complement of N = + 0101011
end carry 0 1101111
1’s complement of 1101111 = 0010000
Answer = - 10000
51
Chapter 01: Binary Systems
Subtraction with 10's complement in Base-11 number system
10-Nov-24
Example : Subtract (72532)11 – (3250)11
10’s complement of (03250)11 is = A A A A A – 0 3 2 5 0 = A 7 8 5 A
Minuend M = 7 2 5 3 2 M = 7 2 5 3 2 M = 7 2 5 3 2
Subtrahend N = 3 2 5 0 N = 0 3 2 5 0 9’s complement of N = + A 7 8 5 A
end carry 1 6 A 2 9 1
+ 1
6 A 2 9 2
Answer = 69282
52
Chapter 01: Binary Systems
Complements
10-Nov-24
Additional Study Notes :
• Prove that “(r-1)’s complement of N is defined as rn – r-m–N”, where N is positive
number, r is base, n is number of digits, m is number of digits for fraction part.
Page -10-11
• Prove that if minuend (M) is smaller than the subtrahend (N), while both M and
N are positive, subtraction is obtained by making complement of the summation
of M and complement of N.
Page-12
53
Chapter 01: Binary Systems
Exercise
10-Nov-24
• Determine the 1’s complement of each binary number:
a) 00011010
b) 11110111
c) 10001101
• Determine the 2’s complement of each binary number:
a) 00010110
b) 11111100
c) 10010001
54
Chapter 01: Binary Systems
Exercise
10-Nov-24
• Determine the 1’s complement of each binary number:
a) 00011010
b) 11110111
c) 10001101
• Determine the 2’s complement of each binary number:
a) 00010110
b) 11111100
c) 10010001
55
Chapter 01: Binary Systems
Binary Codes
10-Nov-24
• When number, alphabets or words are represented by a specific group of
symbols i.e., they are encoded
• The group of symbols used to encode them are called codes. The digital
data is represented, stored and transmitted as a group of binary digits (bits)
• Group of bits binary code Numeric and alphanumeric code
56
Chapter 01: Binary Systems
Classification of Binary Codes
10-Nov-24
58
Chapter 01: Binary Systems
Binary Numbers & Binary Codes
10-Nov-24
• Do NOT mix up conversion of a decimal number to a binary
number with coding a decimal number with a BINARY CODE.
• 1310 = 11012 (This is conversion)
• 13  0001|0011 (This is coding)
59
Chapter 01: Binary Systems
Binary Codes
10-Nov-24
• Given n binary digits (called bits), a binary code
is a mapping from a set of represented
elements to a subset of the 2n binary numbers.
• Example: A binary code for the seven colors of
the rainbow
• Code 100 is not used
Binary Number
000
001
010
011
101
110
111
Color
Red
Orange
Yellow
Green
Blue
Indigo
Violet
Non-Numeric Binary Codes
60
Chapter 01: Binary Systems
Number of bits required
10-Nov-24
• Given M elements to be represented by a binary code, the minimum
number of bits, n, needed, satisfies the following relationships:
2n > M > 2(n – 1)
n = log2 M where x , called the ceiling function, is the integer greater
than or equal to x.
• Example: How many bits are required to represent decimal digits with a
binary code?
61
Chapter 01: Binary Systems
Binary Codes & Decimal Digits
10-Nov-24
Decimal 8,4,2,1 Excess3 8,4,-2,-1 Gray
0 0000 0011 0000 0000
1 0001 0100 0111 0100
2 0010 0101 0110 0101
3 0011 0110 0101 0111
4 0100 0111 0100 0110
5 0101 1000 1011 0010
6 0110 1001 1010 0011
7 0111 1010 1001 0001
8 1000 1011 1000 1001
9 1001 1100 1111 1000
There are over 8,000 ways that you can chose 10 elements from the 16
binary numbers of 4 bits. A few are useful:
2,4,2,1
0000
0001
0010
0011
1011
1100
1101
1110
1111
0100
62
Chapter 01: Binary Systems
Binary Coded Decimal (BCD)
10-Nov-24
• Binary coded decimal (BCD) is a way to express each of the decimal digits
with a binary code. There are only 10 code groups in the BCD system, so it
is very easy to convert between decimal and BCD.
• The 8421 code is a type of BCD code that indicates the binary weights of
the four bits (23, 22 , 21 , 20 ). The 8421 code is the predominant BCD code, and it
is referred to BCD, it is always meant to be the 8421 BCD code.
Decimal/ BCD conversion
63
Chapter 01: Binary Systems
Binary Coded Decimal (BCD)
10-Nov-24
• Invalid Codes
• With 4 bits 16 numbers (0000 through 1111) can be
represented but that, in the 8421 code only 10 of these are
used. The six combinations that are not used- 1010, 1011,
1100, 1101, 1110, and 1111 —are invalid in the 8421 BCD
code.
64
Chapter 01: Binary Systems
Conversion (Decimal to BCD)
10-Nov-24
• Convert each of the following decimal numbers to BCD:
• (a) 35 (b) 98 (c) 170 (d) 2469
Example: Convert the decimal number 9673 to BCD.
65
Chapter 01: Binary Systems
10-Nov-24
• Convert each of the following BCD codes to decimal:
(a) 10000110 (b) 001101010001 (c) 1001010001110000
Example: Convert the BCD code 10000010001001110110 to decimal.
Conversion (BCD to Decimal)
66
Chapter 01: Binary Systems
BCD Addition
10-Nov-24
• BCD is a numerical code and can be used in arithmetic operations.
Addition is the most important operation because the other three
operations (subtraction, multiplication, and division) can be accomplished
by the use of addition. Here is how to add two BCD numbers:
• Step 1: Add the two BCD numbers, using the rules for binary addition.
• Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
• Step 3: 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 six invalid states and return the code to 8421. If a carry results
when 6 is added, simply add the carry to the next 4-bit group
67
Chapter 01: Binary Systems
BCD Addition
10-Nov-24
• Add the following BCD numbers:
• (a) 0011 + 0100
• (b) 00100011 + 00010101
68
Chapter 01: Binary Systems
BCD Addition
10-Nov-24
• Add the following BCD numbers:
• (c) 10000110 + 00010011
• (d) 010001010000 + 010000010111
Note that in each case the sum in any 4-bit column does not exceed 9, and the
results are valid BCD numbers.
Example: Add the BCD numbers: 1001000001000011 + 0000100100100101.
69
Chapter 01: Binary Systems
BCD Addition
10-Nov-24
• Add the following BCD numbers:
• (a) 1001 + 0100
• (b) 1001 + 1001
70
Chapter 01: Binary Systems
BCD Addition
10-Nov-24
• Add the following BCD numbers:
• (c) 00010110 + 00010101
• (d) 01100111 + 01010011
Example : Add the BCD numbers: 01001000 + 00110100.
71
Chapter 01: Binary Systems
Exercise
10-Nov-24
• What is the binary weight of each 1 in the following BCD numbers?
(a)0010 (b) 1000 (c) 0001 (d) 0100
• Convert the following decimal numbers to BCD:
(a)6 (b) 15 (c) 273 (d) 849
• What decimal numbers are represented by each BCD code?
(a) 10001001 (b) 001001111000 (c) 000101010111
• In BCD addition, when is a 4-bit sum invalid?
72
Chapter 01: Binary Systems
Gray Code
10-Nov-24
• The Gray code is unweighted and is not an arithmetic code; that is, there are
no specific weights assigned to the bit positions.
• The important feature of the Gray code is that it exhibits only a single bit
change from one code word to the next in sequence.
• This property is important in many applications, such as shaft position
encoders, where error susceptibility increases with the number of bit changes
between adjacent numbers in a sequence
73
Chapter 01: Binary Systems
Gray Code
10-Nov-24
• What special property does the
Gray code have in relation to
adjacent decimal digits?
Decimal 8,4,2,1 Gray
0 0000 0000
1 0001 0100
2 0010 0101
3 0011 0111
4 0100 0110
5 0101 0010
6 0110 0011
7 0111 0001
8 1000 1001
9 1001 1000
74
Chapter 01: Binary Systems
Gray Code
10-Nov-24
• Going from decimal 3 to decimal 4, the Gray code changes from 0010 to 0110, while the binary code
changes from 0011 to 0100, a change of three bits. The only bit change in the Gray code is in the third
bit from the right: the other bits remain the same.
75
Chapter 01: Binary Systems
Conversion (Binary to Gray Code)
10-Nov-24
• Step- 1: The most significant bit (left-most) in the Gray code is the same
as the corresponding MSB in the binary number.
• Step- 2: Going from left to right, add each adjacent pair of binary code
bits to get the next Gray code bit. Discard carries.
76
Chapter 01: Binary Systems
Conversion (Binary to Gray Code)
10-Nov-24
• Convert the binary number 11000110 to Gray code.
Example: Convert binary 101101 to Gray code.
77
Chapter 01: Binary Systems
Conversion (Gray Code to Binary )
10-Nov-24
• Step- 1: The most significant bit (left-most) in the binary code is the same
as the corresponding bit in the Gray code.
• Step- 2: Add each binary code bit generated to the Gray code bit in the
next adjacent position. Discard carries.
78
Chapter 01: Binary Systems
Conversion (Gray Code to Binary )
10-Nov-24
• Convert the Gray code 10101111 to binary.
Example: Convert Gray code 100111 to binary.
79
Chapter 01: Binary Systems
Alphanumeric Codes
10-Nov-24
• In order to communicate, not only numbers, but also letters and other
symbols are needed.
• Alphanumeric codes are codes that represent numbers and alphabetic
characters (letters). Most such codes, however, also represent other
characters such as symbols and various instructions necessary for conveying
information.
• ASCII is a universally accepted alphanumeric code used in most computers
and other electronic equipment.
80
Chapter 01: Binary Systems
ASCII Character Codes
10-Nov-24
• American Standard Code for Information Interchange
• This code is a popular code used to represent information sent as
character-based data. It uses 7-bits to represent:
• 94 Graphic printing characters.
• 34 Non-printing characters
• Some non-printing characters are used for text format (e.g. BS =
Backspace, CR = carriage return)
• Other non-printing characters are used for record marking and flow
control (e.g. STX and ETX start and end text areas).
81
Chapter 01: Binary Systems
ASCII Character Codes
10-Nov-24
ASCII has some interesting properties:
• Digits 0 to 9 span Hexadecimal values 30₁₆ to 39₁₆.
• Upper case A - Z span 41₁₆ to 5A₁₆.
• Lower case a - z span 61₁₆ to 7A₁₆.
• Lower to upper case translation (and vice versa)
occurs by flipping bit 6.
• Delete (DEL) is all bits set, a carryover from when
punched paper tape was used to store messages.
Punching all holes in a row erased a mistake!
82
Chapter 01: Binary Systems
Unicode
10-Nov-24
A system to encode all characters across the world's languages by assigning
each a unique numeric value (code point) in the universal character set (UCS).
• Supports 100,000+ Characters: Includes text, symbols, and multilingual
scripts.
• Compatibility with ASCII: The first 128 Unicode characters match ASCII,
making ASCII a small subset of Unicode.
• Flexible Encoding: Uses "code points" mapped to sequences of bytes for
different characters.
• Comprehensive Standard: Covers rules for normalization, decomposition,
and supports bidirectional scripts (e.g., Arabic, Hebrew).
83
Chapter 01: Binary Systems
Error Detection Code
10-Nov-24
Message P ( Odd) P (even)
0000 1 0
0001 0 1
0010 0 1
0011 1 0
0100 0 1
0101 1 0
0110 1 0
0111 0 1
1000 0 1
1001 1 0
1010 1 0
1011 0 1
1100 1 0
1101 0 1
1110 0 1
1111 1 0
• Any external noise introduced into a physical communication
media changes the bit values from 0 to 1 or vice versa.
• Redundancy (e.g. extra information), in the form of extra bits,
can be incorporated into binary code words to detect and
correct errors.
• A simple form of redundancy is Parity i.e. an extra bit
included with the message to make the total number of 1’s
either odd or even.
• Parity can detect all single-bit errors and some multiple-bit
errors.
• A code word has even parity if the number of 1’s in the code
word is even.
• A code word has odd parity if the number of 1’s in the code
word is odd.
• An error is detected if the checked parity does not correspond
to the adopted one
84
Chapter 01: Binary Systems
Detecting an Error
10-Nov-24
• A parity bit helps detect a single-bit error (or any odd number of errors), but it cannot
detect two errors in one group.
• We transmit the BCD code 0101. The total code transmitted, including the even parity bit,
is :
Now let’s assume that an error occurs in the third bit from the left (the 1 becomes a 0)
When this code is received, the parity check circuitry determines that there is only a single 1, when
there should be an even number of 1s. Because an even number of 1s does not appear in the code
when it is received, an error is indicated.
85
Chapter 01: Binary Systems
Example
10-Nov-24
• Assign the proper even parity bit to the following code groups:
• (a) 1010 (b) 111000 (c) 101101 (d) 1000111001001 (e) 101101011111
Make the parity bit either 1 or 0 as necessary to make the total number of 1s
even. The parity bit will be the left-most bit (color).
86
Chapter 01: Binary Systems
Example
10-Nov-24
• An odd parity system receives the following code groups: 10110, 11010,
110011, 110101110100, and 1100010101010. Determine which groups, if
any, are in error.
Since odd parity is required, any group with an even number of 1s is
incorrect. The following groups are in error: 110011 and 1100010101010.
Example:
The following ASCII character is received by an odd parity system:
00110111. Is it correct?
87
Chapter 01: Binary Systems
Hamming Code
10-Nov-24
Hamming code is used to detect and correct single-bit errors in
transmitted data.
• Redundancy Bits:
• 4 redundancy bits are added to a 7-bit group of data bits.
• These bits are placed at positions 2ⁿ (n = 0, 1, 2, 3) within
the data.
• Error Correction Process:
• Redundancy bits are interspersed within the data bits
during transmission.
• After transmission, redundancy bits are removed to retrieve
the original data.
88
Chapter 01: Binary Systems
Exercise
10-Nov-24
• .Which odd-parity code is in error?
(a) 1011 (b) 1110 (c) 0101 (d) 1000
• Which even-parity code is in error?
(a) 11000110 (b) 00101000 (c) 10101010 (d) 11111011
• Add an even parity bit to the end of each of the following codes.
(a) 1010100 (b) 0100000 (c) 1110111 (d) 1000110
For Your Attention
Thank You
+8801769021807 Chairman.cse@bup.edu.bd

1.Digital Logic Design (Chap 01, Topic 1,2 - Binary Systems).pdf

  • 1.
    Course Teacher : ColonelS M Saiful Islam, SUP, psc CSE (BUET), MBA (IBA), MDS ITIL® (Expert), Prince2® (Practitioner), CDCP®, ISO 27001 Lead Auditor® Course Title : CSE-1201: Digital Logic Design Credit Hour: 3.0 Department of Computer Science & Engineering Bangladesh University of Professionals Chapter 01 BINARY SYSTEMS
  • 2.
    2 Chapter 01: BinarySystems Learning Objective ▪ Learn various binary systems that are suitable for representing information in digital components. ▪ Understand the binary number system and how it functions. ▪ Explore binary codes and their use in representing decimal and alphanumeric information. ▪ Gain an initial understanding of binary logic from an intuitive perspective. 10-Nov-24
  • 3.
    3 Chapter 01: BinarySystems Overview 1. Digital Systems 2. Binary Numbers 3. Number Base Conversions 4. Octal and Hexadecimal Numbers 5. Complements 6. Signed Binary Numbers 7. Binary Codes 10-Nov-24
  • 4.
    Topic- 1: Introductionto Number Systems and Digital Components (Binary, Octal, Hexadecimal Systems)​ 10-Nov-24 Chapter 01: Binary Systems 4
  • 5.
    5 Chapter 01: BinarySystems Analog Vs Digital System 10-Nov-24 Analog System • The physical quantities or signals may vary continuously over a specified range Digital System • The physical quantities or signals can assume only discrete values • Greater accuracy Analog Signal Digital Signal
  • 6.
    6 Chapter 01: BinarySystems Digital Systems 10-Nov-24 • Digital systems are designed to store, process, and communicate information in digital form. • They are found in a wide range of applications, including process control, communication systems, digital instruments, and consumer products. The digital computer, more commonly called the computer, is an example of a typical digital system. • They are involved in our business transactions, communications, transportation, medical treatment and entertainment. In industrial world they are heavily employed in design, manufacturing, distribution and sales.
  • 7.
    7 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 • Takes a set of discrete information inputs and discrete internal information (system state) and generates a set of discrete information outputs Discrete Information Processing System System State Discrete Inputs Discrete Outputs
  • 8.
    8 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 Discrete Information Processing System System State Discrete Inputs Discrete Outputs • No state present • Combinational Logic System • Output = Function (Input) • State present • State updated at discrete times • Synchronous Sequential System • State updated at any time • Asynchronous Sequential System • State = Function (State, Input) • Output = Function (State) or Function (State, Input)
  • 9.
    9 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 A Digital Counter (e. g., odometer): Synchronous or Asynchronous? 1 3 0 0 5 6 4 Count Up Reset Inputs: Count Up, Reset Outputs: Visual Display State: "Value" of stored digits
  • 10.
    10 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 Synchronous or Asynchronous? Inputs: Keyboard, mouse, modem, microphone Outputs: CRT, LCD, modem, speakers Memory Control unit Datapath Input/Output CPU
  • 11.
    11 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 Synchronous or Asynchronous? • An information variable represented by physical quantity. • For digital systems, the variable takes on discrete values. • Two level, or binary values are the most prevalent values in digital systems. • Binary values are represented abstractly by: • digits 0 and 1 • words (symbols) False (F) and True (T) • words (symbols) Low (L) and High (H) • and words On and Off. • Binary values are represented by values or ranges of values of physical quantities
  • 12.
    12 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 Analog Asynchronous Synchronous Time Continuous in value & time Discrete in value & continuous in time Discrete in value & time Digital Signal
  • 13.
    13 Chapter 01: BinarySystems Digital Systems (contd…) 10-Nov-24 Binary Digital Signal • An information variable represented by physical quantity. • For digital systems, the variable takes on discrete values. • Two level, or binary values are the most prevalent values • Binary values are abstractly represented by: • Digits 0 and 1 • Words (symbols) False (F) and True (T) • Words (symbols) Low (L) and High (H) • And words On and Off • Binary values are represented by values or ranges of values of physical quantities Binary Digital Signal
  • 14.
    14 Chapter 01: BinarySystems Number Systems 10-Nov-24 • Integers are normally written using positional number system, in which each digit represents the coefficient in a power series N = 𝑎𝑛−1 𝑟𝑛 − 1 + 𝑎𝑛−2 𝑟𝑛 − 2 + ⋯ + 𝑎2 𝑟2 + 𝑎1 𝑟1 + 𝑎0 Where, n is the number of digit r is the radix or base 𝑎𝑖 is the coefficient 0 ≤ 𝑎𝑖 ≤ r • There are four systems of arithmetic which are often used in digital circuit
  • 15.
    15 Chapter 01: BinarySystems Number Systems 10-Nov-24 N = 𝑎𝑛−1 𝑟𝑛 − 1 + 𝑎𝑛−2 𝑟𝑛 − 2 + ⋯ + 𝑎2 𝑟2 + 𝑎1 𝑟1 + 𝑎0 0 ≤ 𝑎𝑖 ≤ r 2073 = 2 𝑥 103 + 0 𝑥102 + 7𝑥101 + 3 233 = 2 𝑥 82 + 3𝑥81 + 3 2A9 = 2 𝑥 162 + 𝐴𝑥161 + 9
  • 16.
    16 Chapter 01: BinarySystems Number Systems (contd…) 10-Nov-24 • Decimal: it has a base (r = 10) and coefficients (a) are in the range 0 to 9 • Binary: it has a base (r = 2) and coefficients (a) are all either 0 or 1 • Octal: it has a base (r = 8) and coefficients (a) are in the range 0 to 7 • Hexadecimal: it has a base (r = 16) and coefficients (a) are in the range {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
  • 17.
    17 Chapter 01: BinarySystems Number Systems (contd…) 10-Nov-24 General Decimal Binary Radix (Base) r 10 2 Digits 0 => r - 1 0 => 9 0 => 1 0 1 2 3 Powers of 4 Radix 5 -1 -2 -3 -4 -5 r0 r1 r2 r3 r4 r5 r -1 r -2 r -3 r -4 r -5 1 10 100 1000 10,000 100,000 0.1 0.01 0.001 0.0001 0.00001 1 2 4 8 16 32 0.5 0.25 0.125 0.0625 0.03125
  • 18.
    18 Chapter 01: BinarySystems Number Systems (contd…) 10-Nov-24 Commonly Occurring Bases Name Radix Digits Binary 2 0,1 Octal 8 0,1,2,3,4,5,6,7 Decimal 10 0,1,2,3,4,5,6,7,8,9 Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
  • 19.
    19 Chapter 01: BinarySystems Number Systems (contd…) 10-Nov-24 Decimal (Base 10) Binary (Base 2) Octal (Base 8) Hexadecimal (Base 16) 00 00000 00 00 01 00001 01 01 02 00010 02 02 03 00011 03 03 04 00100 04 04 05 00101 05 05 06 00110 06 06 07 00111 07 07 08 01000 10 08 09 01001 11 09 10 01010 12 0A 11 01011 13 0B 12 01100 14 0C 13 01101 15 0D 14 01110 16 0E 15 01111 17 0F 16 10000 20 10
  • 20.
    20 Chapter 01: BinarySystems Number Systems (contd…) 10-Nov-24 210 (1024) is Kilo, denoted "K" 220 (1,048,576) is Mega, denoted "M" 230 is Giga, denoted "G" Exponent Value Exponent Value 0 1 11 2,048 1 2 12 4,096 2 4 13 8,192 3 8 14 16,384 4 16 15 32,768 5 32 16 65,536 6 64 17 131,072 7 128 18 262,144 19 524,288 20 1,048,576 21 2,097,152 8 256 9 512 10 1024 240 is Tera, denoted "G" 250 is Peta, denoted “P"
  • 21.
    21 Chapter 01: BinarySystems Number Systems (contd…) 10-Nov-24 (73925)10 = 7*104 + 3*103 + 9*102 + 2*101 + 5*100 (a4 a3 a2 a1 a0)10 = a4 *104 + a3*103 + a2*102 + a1 *101 + a0*100 (a4 a3 a2 a1 a0)r = a4 *r4 + a3*r3 + a2*r2 + a1 *r1 + a0*r0 (an an-1 ………a2 a1 a0)r = an *rn + an-1*rn-1 + …… + a2*r2 + a1 *r1 + a0*r0 (73925.613)10 = 7*104 + 3*103 + 9*102 + 2*101 + 5*100 + 6*10-1 + 1*10-2 + 3*10-3 (an an-1 ………a2 a1 a0.a-1 a-2 ......a-m)r = an *rn + an-1*rn-1 + …… + a2*r2 + a1 *r1 + a0*r0 + a-1*r-1 + a-2 *r-2 + ………… + a-m*r-m
  • 22.
    22 Chapter 01: BinarySystems Binary Arithmetic 10-Nov-24 • Binary arithmetic is essential in all digital computers and in many other types of digital systems. • To understand digital systems, one must know the basics of • Binary Addition • Binary Subtraction • Binary Multiplication • Binary Division
  • 23.
    23 Chapter 01: BinarySystems Binary Arithmetic (contd…) 10-Nov-24 Binary Addition Carry
  • 24.
    24 Chapter 01: BinarySystems Binary Arithmetic (contd…) 10-Nov-24 Binary Subtraction Borrow a “Base” when needed
  • 25.
    25 Chapter 01: BinarySystems Binary Arithmetic (contd…) 10-Nov-24 Binary Multiplication Bit by Bit
  • 26.
    26 Chapter 01: BinarySystems Binary Arithmetic (contd…) 10-Nov-24 Binary Division 101 110111 -101 111 -101 0101 -101 0 1011 Division in binary follows the same procedure as division in decimal.
  • 27.
    27 Chapter 01: BinarySystems Exercise 10-Nov-24 • Perform the following binary additions: a) 1101 + 1010 b) 10111 + 01101 • Perform the following binary subtractions: a) 1101 – 0100 b) 1001 – 0111 • Perform the indicated binary operations: a) 110 × 111 b) 1100 ÷ 011
  • 28.
    Topic- 2: ConversionsBetween Number Systems, Complements and Codes​ 10-Nov-24 Chapter 01: Binary Systems 28
  • 29.
    29 Chapter 01: BinarySystems Conversion Between Bases 10-Nov-24 1) Convert the Integer Part: Repeatedly divide the number by the new radix and save the remainders. The digits for the new radix are the remainders in reverse order of their computation. If the new radix is > 10, then convert all remainders > 10 to digits A, B, … 2) Convert the Fractional Part: Repeatedly multiply the fraction by the new radix and save the integer digits that result. The digits for the new radix are the integer digits in order of their computation. If the new radix is > 10, then convert all integers > 10 to digits A, B, … 3) Join the two results with a radix point
  • 30.
    30 Chapter 01: BinarySystems Conversion Between Bases (Binary-to-Decimal) 10-Nov-24 (a) Integer (b) Fraction 110102 =1*24 + 1*23 + 0*22 + 1*21 + 0*20 = 16 + 8 + 0 + 2 + 0 = (26)10 1011102 = 1*25 + 0*24 + 1*23 + 1*22 + 1*21+ 0*20 = 32 + 8 + 4 + 2 = (46)10
  • 31.
    31 Chapter 01: BinarySystems 10-Nov-24 (a) Integer (b) Fraction 25 ÷ 2 = 12 +1 12 ÷ 2 = 6 +0 6 ÷ 2 = 3 +0 3 ÷ 2 = 1 +1 1 ÷ 2 = 0 +1 2510 = 110012 0.625 × 2 = 1.25 = 0.25 + 1 0.25 × 2 = 0.5 = 0.5 + 0 0.5 × 2 = 1.0 = 0.0 + 1 0.62510 = 0.1012 Conversion Between Bases (Decimal-to-Binary)
  • 32.
    32 Chapter 01: BinarySystems Conversion Between Bases (Decimal-to-Octal) 10-Nov-24 (a) Integer (b) Fraction 3928610 = 1145668 0.34210 = 0.25708
  • 33.
    33 Chapter 01: BinarySystems 10-Nov-24 (a) Integer (b) Fraction 1408 = 9610 1725.438 = 981.54687510 Conversion Between Bases (Octal-to-Decimal)
  • 34.
    34 Chapter 01: BinarySystems 10-Nov-24 (a) Integer (b) Fraction Conversion Between Bases (Decimal-to-Hexadecimal)
  • 35.
    35 Chapter 01: BinarySystems 10-Nov-24 (a) Integer (b) Fraction 54.D216 = 84.820312510 Conversion Between Bases (Hexadecimal-to-Decimal)
  • 36.
    36 Chapter 01: BinarySystems 10-Nov-24 Works both ways (Binary to Octal & Octal to Binary) 10110.012 = 26.28 Conversion Between Bases (Binary to/from Octal)
  • 37.
    37 Chapter 01: BinarySystems 10-Nov-24 10110.012 = 16.416 Conversion Between Bases (Binary to/from Hexadecimal)
  • 38.
    38 Chapter 01: BinarySystems 10-Nov-24 26.28 = 16.416 Conversion Between Bases (Octal to/from Hexadecimal)
  • 39.
    39 Chapter 01: BinarySystems 10-Nov-24 Conversion of Binary to Octal & Hexadecimal (10110001101011 . 111100000110)2 = (26153.7406)8 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 . 1 1 1 1 0 0 0 0 0 1 1 0 2 6 1 5 3 . 7 4 0 6 (10110001101011 . 111100000110)2 = (2C6B.F06)16 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 . 1 1 1 1 0 0 0 0 0 1 1 0 2 C 6 B F 0 6 Conversion Between Bases (Binary to/from Hexadecimal)
  • 40.
    40 Chapter 01: BinarySystems 10-Nov-24 Conversion of Hexadecimal-to-Binary-to-Octal Hexa 2 C 6 B F 0 6 Binary 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 . 1 1 1 1 0 0 0 0 0 1 1 0 Octal 2 6 1 5 3 7 4 0 6 (2C6B.F06)16 = (26153.7406)8 Conversion Between Bases (Binary to/from Hexadecimal)
  • 41.
    41 Chapter 01: BinarySystems Exercise 10-Nov-24 • Convert the decimal number 250.5 to base 3, base 4, base 7, base 8, and base 16. • Convert the following decimal numbers to binary: 12.0625, 104, 673.23, and 1998. • Convert the following binary numbers to decimal: 10.10001, 101110.0101, 1110101.0101, 1110101.110. • Convert the following numbers from the given base to the bases indicated: a) Decimal 225.225 to binary, octal, and hexadecimal b) Binary 11010111.110 to decimal, octal, and hexadecimal c) Octal 623.77 to decimal, binary, and hexadecimal d) Hexadecimal 2AC5.D to decimal, octal, and binary
  • 42.
    42 Chapter 01: BinarySystems Complements 10-Nov-24 • Complements are used in digital computers for simplifying the subtraction operation and for logical manipulations. • There are two types of complements for each base-r system: • r’s complement • (r-1)’s complement
  • 43.
    43 Chapter 01: BinarySystems Complements 10-Nov-24 r's complement of (N)r = rn - N • 10's of (52520)10 = 105 – 52520 = 47480 • 10's of (0.3267)10 = 1 - 0.3267 = 0.6733 • 10's of (25.639)10 = 102 - 25.639 = 74.631 • 2's of (101100)2 = 26 – 101100 = 100000 – 101100 = (010100)2 • 2's of (0.0110)2 = 1 - 0.0110 = 0.1010
  • 44.
    44 Chapter 01: BinarySystems Complements 10-Nov-24 (r-1)'s complement of (N)r = rn -1- N rn -1 = (r-1) (r-1) ……… (r-1) (r-1) (r-1) ….. up to n i.e. 105 -1 = 99999 ( five digits of 9) • 9's of (52520)10 = 99999 – 52520 = 47479 • 9's of (0.3267)10 = 0.9999 - 0.3267 = 0.6732 • 9's of (25.639)10 = 99.999 - 25.639 = 74.630 • 1's of (101100)2 = 111111 – 101100 = (010011)2 • 1's of (0.0110)2 = 0.1111 - 0.0110 = 0.1001
  • 45.
    45 Chapter 01: BinarySystems Subtraction with Complements 10-Nov-24 Subtraction with r's complement • Make the minuend and subtrahend equal in digits • Add the minuend to the r's complement of the subtrahend • If and end-carry occurs, ignore it • If there is no end carry, make the r's complement of the result and place a negative sign in front.
  • 46.
    46 Chapter 01: BinarySystems Subtraction with 10's complement 10-Nov-24 Example : Subtract 72532 - 3250 Minuend M = 7 2 5 3 2 M = 7 2 5 3 2 M = 7 2 5 3 2 Subtrahend N = 3 2 5 0 N = 0 3 2 5 0 10's complement of N = + 9 6 7 5 0 end carry 1 6 9 2 8 2 Answer = 69282 Example : Subtract 3250 - 72532 Minuend M = 3 2 5 0 M = 0 3 2 5 0 M = 0 3 2 5 0 Subtrahend N = 7 2 5 3 2 N = 7 2 5 3 2 10's complement of N = + 2 7 4 6 8 end carry 0 3 0 7 1 8 10's complement of 30718 = 69282 Answer = ‒ 69282
  • 47.
    47 Chapter 01: BinarySystems Subtraction with 2's complement 10-Nov-24 Example : Subtract 1010100 – 1000100 Minuend M = 1010100 M = 1010100 Subtrahend N = 1000100 2’s complement of N = + 0111100 end carry 1 0010000 Answer = 10000 Example : Subtract 1000100 – 1010100 Minuend M = 1000100 M = 1000100 Subtrahend N = 1010100 2’s complement of N = + 0101100 end carry 0 1110000 2’s complement of 1110000 = 10000 Answer = - 10000
  • 48.
    48 Chapter 01: BinarySystems Subtraction with (r-1)'s complement 10-Nov-24 • Make the minuend and subtrahend equal in digits • Add the minuend to the (r-1)'s complement of the subtrahend • If and end-carry occurs, add 1 with the result • If there is no end carry, make the (r-1)'s complement of the result and place a negative sign in front.
  • 49.
    49 Chapter 01: BinarySystems Subtraction with 9's complement 10-Nov-24 Example: Subtract 3250 - 72532 Minuend M = 3 2 5 0 M = 0 3 2 5 0 M = 0 3 2 5 0 Subtrahend N = 7 2 5 3 2 N = 7 2 5 3 2 9’s complement of N = + 2 7 4 6 7 end carry 0 3 0 7 1 7 9’s complement of 30717 = 69282 Answer = - 69282 Example : Subtract 72532 - 3250 Minuend M = 7 2 5 3 2 M = 7 2 5 3 2 M = 7 2 5 3 2 Subtrahend N = 3 2 5 0 N = 0 3 2 5 0 9’s complement of N = + 9 6 7 4 9 end carry 1 6 9 2 8 1 + 1 6 9 2 8 2 Answer = 69282
  • 50.
    50 Chapter 01: BinarySystems Subtraction with 1's complement 10-Nov-24 Example : Subtract 1010100 – 1000100 Minuend M = 1010100 M = 1010100 Subtrahend N = 1000100 1’s complement of N = + 0111011 end carry 1 0001111 + 1 0010000 Answer = 10000 Example : Subtract 1000100 – 1010100 Minuend M = 1000100 M = 1000100 Subtrahend N = 1010100 1’s complement of N = + 0101011 end carry 0 1101111 1’s complement of 1101111 = 0010000 Answer = - 10000
  • 51.
    51 Chapter 01: BinarySystems Subtraction with 10's complement in Base-11 number system 10-Nov-24 Example : Subtract (72532)11 – (3250)11 10’s complement of (03250)11 is = A A A A A – 0 3 2 5 0 = A 7 8 5 A Minuend M = 7 2 5 3 2 M = 7 2 5 3 2 M = 7 2 5 3 2 Subtrahend N = 3 2 5 0 N = 0 3 2 5 0 9’s complement of N = + A 7 8 5 A end carry 1 6 A 2 9 1 + 1 6 A 2 9 2 Answer = 69282
  • 52.
    52 Chapter 01: BinarySystems Complements 10-Nov-24 Additional Study Notes : • Prove that “(r-1)’s complement of N is defined as rn – r-m–N”, where N is positive number, r is base, n is number of digits, m is number of digits for fraction part. Page -10-11 • Prove that if minuend (M) is smaller than the subtrahend (N), while both M and N are positive, subtraction is obtained by making complement of the summation of M and complement of N. Page-12
  • 53.
    53 Chapter 01: BinarySystems Exercise 10-Nov-24 • Determine the 1’s complement of each binary number: a) 00011010 b) 11110111 c) 10001101 • Determine the 2’s complement of each binary number: a) 00010110 b) 11111100 c) 10010001
  • 54.
    54 Chapter 01: BinarySystems Exercise 10-Nov-24 • Determine the 1’s complement of each binary number: a) 00011010 b) 11110111 c) 10001101 • Determine the 2’s complement of each binary number: a) 00010110 b) 11111100 c) 10010001
  • 55.
    55 Chapter 01: BinarySystems Binary Codes 10-Nov-24 • When number, alphabets or words are represented by a specific group of symbols i.e., they are encoded • The group of symbols used to encode them are called codes. The digital data is represented, stored and transmitted as a group of binary digits (bits) • Group of bits binary code Numeric and alphanumeric code
  • 56.
    56 Chapter 01: BinarySystems Classification of Binary Codes 10-Nov-24
  • 57.
    58 Chapter 01: BinarySystems Binary Numbers & Binary Codes 10-Nov-24 • Do NOT mix up conversion of a decimal number to a binary number with coding a decimal number with a BINARY CODE. • 1310 = 11012 (This is conversion) • 13  0001|0011 (This is coding)
  • 58.
    59 Chapter 01: BinarySystems Binary Codes 10-Nov-24 • Given n binary digits (called bits), a binary code is a mapping from a set of represented elements to a subset of the 2n binary numbers. • Example: A binary code for the seven colors of the rainbow • Code 100 is not used Binary Number 000 001 010 011 101 110 111 Color Red Orange Yellow Green Blue Indigo Violet Non-Numeric Binary Codes
  • 59.
    60 Chapter 01: BinarySystems Number of bits required 10-Nov-24 • Given M elements to be represented by a binary code, the minimum number of bits, n, needed, satisfies the following relationships: 2n > M > 2(n – 1) n = log2 M where x , called the ceiling function, is the integer greater than or equal to x. • Example: How many bits are required to represent decimal digits with a binary code?
  • 60.
    61 Chapter 01: BinarySystems Binary Codes & Decimal Digits 10-Nov-24 Decimal 8,4,2,1 Excess3 8,4,-2,-1 Gray 0 0000 0011 0000 0000 1 0001 0100 0111 0100 2 0010 0101 0110 0101 3 0011 0110 0101 0111 4 0100 0111 0100 0110 5 0101 1000 1011 0010 6 0110 1001 1010 0011 7 0111 1010 1001 0001 8 1000 1011 1000 1001 9 1001 1100 1111 1000 There are over 8,000 ways that you can chose 10 elements from the 16 binary numbers of 4 bits. A few are useful: 2,4,2,1 0000 0001 0010 0011 1011 1100 1101 1110 1111 0100
  • 61.
    62 Chapter 01: BinarySystems Binary Coded Decimal (BCD) 10-Nov-24 • Binary coded decimal (BCD) is a way to express each of the decimal digits with a binary code. There are only 10 code groups in the BCD system, so it is very easy to convert between decimal and BCD. • The 8421 code is a type of BCD code that indicates the binary weights of the four bits (23, 22 , 21 , 20 ). The 8421 code is the predominant BCD code, and it is referred to BCD, it is always meant to be the 8421 BCD code. Decimal/ BCD conversion
  • 62.
    63 Chapter 01: BinarySystems Binary Coded Decimal (BCD) 10-Nov-24 • Invalid Codes • With 4 bits 16 numbers (0000 through 1111) can be represented but that, in the 8421 code only 10 of these are used. The six combinations that are not used- 1010, 1011, 1100, 1101, 1110, and 1111 —are invalid in the 8421 BCD code.
  • 63.
    64 Chapter 01: BinarySystems Conversion (Decimal to BCD) 10-Nov-24 • Convert each of the following decimal numbers to BCD: • (a) 35 (b) 98 (c) 170 (d) 2469 Example: Convert the decimal number 9673 to BCD.
  • 64.
    65 Chapter 01: BinarySystems 10-Nov-24 • Convert each of the following BCD codes to decimal: (a) 10000110 (b) 001101010001 (c) 1001010001110000 Example: Convert the BCD code 10000010001001110110 to decimal. Conversion (BCD to Decimal)
  • 65.
    66 Chapter 01: BinarySystems BCD Addition 10-Nov-24 • BCD is a numerical code and can be used in arithmetic operations. Addition is the most important operation because the other three operations (subtraction, multiplication, and division) can be accomplished by the use of addition. Here is how to add two BCD numbers: • Step 1: Add the two BCD numbers, using the rules for binary addition. • Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number. • Step 3: 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 six invalid states and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit group
  • 66.
    67 Chapter 01: BinarySystems BCD Addition 10-Nov-24 • Add the following BCD numbers: • (a) 0011 + 0100 • (b) 00100011 + 00010101
  • 67.
    68 Chapter 01: BinarySystems BCD Addition 10-Nov-24 • Add the following BCD numbers: • (c) 10000110 + 00010011 • (d) 010001010000 + 010000010111 Note that in each case the sum in any 4-bit column does not exceed 9, and the results are valid BCD numbers. Example: Add the BCD numbers: 1001000001000011 + 0000100100100101.
  • 68.
    69 Chapter 01: BinarySystems BCD Addition 10-Nov-24 • Add the following BCD numbers: • (a) 1001 + 0100 • (b) 1001 + 1001
  • 69.
    70 Chapter 01: BinarySystems BCD Addition 10-Nov-24 • Add the following BCD numbers: • (c) 00010110 + 00010101 • (d) 01100111 + 01010011 Example : Add the BCD numbers: 01001000 + 00110100.
  • 70.
    71 Chapter 01: BinarySystems Exercise 10-Nov-24 • What is the binary weight of each 1 in the following BCD numbers? (a)0010 (b) 1000 (c) 0001 (d) 0100 • Convert the following decimal numbers to BCD: (a)6 (b) 15 (c) 273 (d) 849 • What decimal numbers are represented by each BCD code? (a) 10001001 (b) 001001111000 (c) 000101010111 • In BCD addition, when is a 4-bit sum invalid?
  • 71.
    72 Chapter 01: BinarySystems Gray Code 10-Nov-24 • The Gray code is unweighted and is not an arithmetic code; that is, there are no specific weights assigned to the bit positions. • The important feature of the Gray code is that it exhibits only a single bit change from one code word to the next in sequence. • This property is important in many applications, such as shaft position encoders, where error susceptibility increases with the number of bit changes between adjacent numbers in a sequence
  • 72.
    73 Chapter 01: BinarySystems Gray Code 10-Nov-24 • What special property does the Gray code have in relation to adjacent decimal digits? Decimal 8,4,2,1 Gray 0 0000 0000 1 0001 0100 2 0010 0101 3 0011 0111 4 0100 0110 5 0101 0010 6 0110 0011 7 0111 0001 8 1000 1001 9 1001 1000
  • 73.
    74 Chapter 01: BinarySystems Gray Code 10-Nov-24 • Going from decimal 3 to decimal 4, the Gray code changes from 0010 to 0110, while the binary code changes from 0011 to 0100, a change of three bits. The only bit change in the Gray code is in the third bit from the right: the other bits remain the same.
  • 74.
    75 Chapter 01: BinarySystems Conversion (Binary to Gray Code) 10-Nov-24 • Step- 1: The most significant bit (left-most) in the Gray code is the same as the corresponding MSB in the binary number. • Step- 2: Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit. Discard carries.
  • 75.
    76 Chapter 01: BinarySystems Conversion (Binary to Gray Code) 10-Nov-24 • Convert the binary number 11000110 to Gray code. Example: Convert binary 101101 to Gray code.
  • 76.
    77 Chapter 01: BinarySystems Conversion (Gray Code to Binary ) 10-Nov-24 • Step- 1: The most significant bit (left-most) in the binary code is the same as the corresponding bit in the Gray code. • Step- 2: Add each binary code bit generated to the Gray code bit in the next adjacent position. Discard carries.
  • 77.
    78 Chapter 01: BinarySystems Conversion (Gray Code to Binary ) 10-Nov-24 • Convert the Gray code 10101111 to binary. Example: Convert Gray code 100111 to binary.
  • 78.
    79 Chapter 01: BinarySystems Alphanumeric Codes 10-Nov-24 • In order to communicate, not only numbers, but also letters and other symbols are needed. • Alphanumeric codes are codes that represent numbers and alphabetic characters (letters). Most such codes, however, also represent other characters such as symbols and various instructions necessary for conveying information. • ASCII is a universally accepted alphanumeric code used in most computers and other electronic equipment.
  • 79.
    80 Chapter 01: BinarySystems ASCII Character Codes 10-Nov-24 • American Standard Code for Information Interchange • This code is a popular code used to represent information sent as character-based data. It uses 7-bits to represent: • 94 Graphic printing characters. • 34 Non-printing characters • Some non-printing characters are used for text format (e.g. BS = Backspace, CR = carriage return) • Other non-printing characters are used for record marking and flow control (e.g. STX and ETX start and end text areas).
  • 80.
    81 Chapter 01: BinarySystems ASCII Character Codes 10-Nov-24 ASCII has some interesting properties: • Digits 0 to 9 span Hexadecimal values 30₁₆ to 39₁₆. • Upper case A - Z span 41₁₆ to 5A₁₆. • Lower case a - z span 61₁₆ to 7A₁₆. • Lower to upper case translation (and vice versa) occurs by flipping bit 6. • Delete (DEL) is all bits set, a carryover from when punched paper tape was used to store messages. Punching all holes in a row erased a mistake!
  • 81.
    82 Chapter 01: BinarySystems Unicode 10-Nov-24 A system to encode all characters across the world's languages by assigning each a unique numeric value (code point) in the universal character set (UCS). • Supports 100,000+ Characters: Includes text, symbols, and multilingual scripts. • Compatibility with ASCII: The first 128 Unicode characters match ASCII, making ASCII a small subset of Unicode. • Flexible Encoding: Uses "code points" mapped to sequences of bytes for different characters. • Comprehensive Standard: Covers rules for normalization, decomposition, and supports bidirectional scripts (e.g., Arabic, Hebrew).
  • 82.
    83 Chapter 01: BinarySystems Error Detection Code 10-Nov-24 Message P ( Odd) P (even) 0000 1 0 0001 0 1 0010 0 1 0011 1 0 0100 0 1 0101 1 0 0110 1 0 0111 0 1 1000 0 1 1001 1 0 1010 1 0 1011 0 1 1100 1 0 1101 0 1 1110 0 1 1111 1 0 • Any external noise introduced into a physical communication media changes the bit values from 0 to 1 or vice versa. • Redundancy (e.g. extra information), in the form of extra bits, can be incorporated into binary code words to detect and correct errors. • A simple form of redundancy is Parity i.e. an extra bit included with the message to make the total number of 1’s either odd or even. • Parity can detect all single-bit errors and some multiple-bit errors. • A code word has even parity if the number of 1’s in the code word is even. • A code word has odd parity if the number of 1’s in the code word is odd. • An error is detected if the checked parity does not correspond to the adopted one
  • 83.
    84 Chapter 01: BinarySystems Detecting an Error 10-Nov-24 • A parity bit helps detect a single-bit error (or any odd number of errors), but it cannot detect two errors in one group. • We transmit the BCD code 0101. The total code transmitted, including the even parity bit, is : Now let’s assume that an error occurs in the third bit from the left (the 1 becomes a 0) When this code is received, the parity check circuitry determines that there is only a single 1, when there should be an even number of 1s. Because an even number of 1s does not appear in the code when it is received, an error is indicated.
  • 84.
    85 Chapter 01: BinarySystems Example 10-Nov-24 • Assign the proper even parity bit to the following code groups: • (a) 1010 (b) 111000 (c) 101101 (d) 1000111001001 (e) 101101011111 Make the parity bit either 1 or 0 as necessary to make the total number of 1s even. The parity bit will be the left-most bit (color).
  • 85.
    86 Chapter 01: BinarySystems Example 10-Nov-24 • An odd parity system receives the following code groups: 10110, 11010, 110011, 110101110100, and 1100010101010. Determine which groups, if any, are in error. Since odd parity is required, any group with an even number of 1s is incorrect. The following groups are in error: 110011 and 1100010101010. Example: The following ASCII character is received by an odd parity system: 00110111. Is it correct?
  • 86.
    87 Chapter 01: BinarySystems Hamming Code 10-Nov-24 Hamming code is used to detect and correct single-bit errors in transmitted data. • Redundancy Bits: • 4 redundancy bits are added to a 7-bit group of data bits. • These bits are placed at positions 2ⁿ (n = 0, 1, 2, 3) within the data. • Error Correction Process: • Redundancy bits are interspersed within the data bits during transmission. • After transmission, redundancy bits are removed to retrieve the original data.
  • 87.
    88 Chapter 01: BinarySystems Exercise 10-Nov-24 • .Which odd-parity code is in error? (a) 1011 (b) 1110 (c) 0101 (d) 1000 • Which even-parity code is in error? (a) 11000110 (b) 00101000 (c) 10101010 (d) 11111011 • Add an even parity bit to the end of each of the following codes. (a) 1010100 (b) 0100000 (c) 1110111 (d) 1000110
  • 88.
    For Your Attention ThankYou +8801769021807 Chairman.cse@bup.edu.bd