TON DUC THANG UNIVERSITY
FACULTY OF ELECTRICAL & ELECTRONICS ENGINEERING
DEPARTMENT OF ELECTRONICS & TELECOMMUNICATIONS ENGINEERING
CHAPTER 2: NUMBER
SYSTEMS, OPERATIONS,
AND CODES
DIGITAL SYSTEM DESIGN 1
402061
ACKNOWLEDGEMENT
The picture content of this slide is from
Thomas L. Floyd, [2015],Digital Fundamentals,
11e. Prentice Hall.
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 2
OUTLINE
1. Binary numbers
2. Basic operations in binary numbers
3. 1’s and 2’s complements, signed numbers and operations
4. Octal and hexadecimal numbers
5. Binary coded decimal (BCD), digital codes, and error
codes
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 3
OBJECTIVES
Count in binary number system, convert
between decimal numbers and binary numbers
Apply arithmetic operations to binary
numbers
Determine the 1’s and 2’s complements of a
binary number
Signed binary numbers
Carry out arithmetic operations with signed
binary numbers
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 4
OBJECTIVES
Convert between number systems: DEC,
BIN, HEX, OCT
Express decimal numbers in BCD form
Add BCD number
Convert between the binary system and the
Gray code
ASCII
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 5
BINARY SYSTEM
Base 2
2 symbols: 0 and 1
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 6
BINARY COUNTING
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 7
BINARY COUNTING
Digital counters frequently have the same
pattern of digits
Counter 0 1 0 1 0 1 0 1 0 1 Decoder
0 0 1 1 0 0 1 1 0 0
0 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0 1 1
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 8
BINARY TO DECIMAL CONVERSION
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 9
DECIMAL TO BINARY CONVERSION
For a decimal number: repeatedly dividing by
the base
49 DEC ? BIN
For a decimal fraction: repeatedly multiplying
by 2
0.188DEC ? BIN
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 10
BINARY ADDITION
Rules for binary addition:
0 + 0 = 0 Sum = 0, carry = 0
0 + 1 = 0 Sum = 1, carry = 0
1 + 0 = 0 Sum = 1, carry = 0
1 + 1 = 10 Sum = 0, carry = 1
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 11
BINARY SUBTRACTION
Rules for binary subtraction:
0-0=0
1-0=1
1-1=0
10 - 1 = 1 with a borrow of 1
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 12
1’s COMPLEMENT
1’s complement of a binary number is the
inverse of the digits.
Digital circuit: using inverters
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 13
2’S COMPLEMENT
2’s complement = 1’s complement + 1
Digital circuit:
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 14
SIGNED BINARY NUMBERS
MSB is the sign bit
MSB = 0: positive number
MSB = 1: negative number
For signed number, the weight of MSB is
always negative
27
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 15
SIGNED BINARY NUMBERS
Negative numbers are written as the 2’s
complement of the corresponding positive
numbers
5 ? BIN
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 16
ARITHMETIC OPERATIONS
with signed numbers
Addition: discard any final carries
(The result is already in signed form)
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 17
ARITHMETIC OPERATIONS
with signed numbers
Overflow: occurs when numbers of bit for the
answer exceed.
Only happen when adding numbers with the
same sign.
The overflow will be indicated by the change
of the sign bit.
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 18
HEXADECIMAL NUMBERS
Decimal Hexadecimal Binary
Hex uses 16 characters 0 0 0000
to represent numbers 1 1 0001
2 2 0010
Base: 16 3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
3/24/2016 15 CODESF
402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND 19 1111
HEXADECIMAL NUMBERS
Convert from binary number: group 4 bits
Convert to decimal number:
1A2 F ? DEC
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 20
OCTAL NUMBERS
Decimal Octal Binary
Use 8 characters 0 0 0000
1 1 0001
to represent numbers 2 2 0010
Base: 8 3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 10 1000
9 11 1001
10 12 1010
11 13 1011
12 14 1100
13 15 1101
14 16 1110
3/24/2016 15 CODES
402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND 17 1111
21
OCTAL NUMBERS
Convert from binary number: group 3 bits
Convert to decimal number:
1356OCT ? DEC
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 22
BINARY CODED DECIMAL (BCD)
Use 4 bits to represent decimal numbers
(09)
BCD is commonly used in digital system
Decimal Binary BCD
Applications: digital clocks, 0 0000 0000
digital thermometers, and other 1 0001 0001
2 0010 0010
devices with 7-segment displays 3 0011 0011
4 0100 0100
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 23
BCD ADDITION
Step 1: Add 2 BCD
numbers, using rules for
binary addition
Step 2: If the result is
less than 9 valid BCD
Step 3: If the result is
more than 9 invalid BCD
Add 6 (0110) to the
result to get valid BCD
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 24
DIGITAL CODES, ERROR DETECTION
& CORRECTION CODES
ASSIGNMENT: Find out about the following
information:
The Gray Code
The advantage of the Gray Code
Convert between Gray Code and Binary
ASCII vs. Unicode
Error detection codes
Parity method
Cyclic Redundancy Check (CRC)
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 25
SUMMARY
In this chapter, we have learned:
how to count in different number systems,
convert between number systems: DEC, BIN,
HEX, OCT
arithmetic operations to binary numbers
the 1’s and 2’s complements of a binary
number
signed binary numbers and their arithmetic
operations
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 26
SUMMARY
In this chapter, we have learned:
the expression of decimal numbers in BCD
form
addition of BCD number
Gray code and ASCII
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 27
HW #2
DIGITAL FUNDAMENTALS 11th edition (borrow
from the library)
Prob: pg 117 – 121 every odd problem
Prepare chap 3: Logic gates
3/24/2016 402061 - CHAP 2: NUMBER SYSTEMS, OPERATIONS, AND CODES 28