Digital System Topic 1
Digital System Topic 1
NUMBER SYSTEMS
AND CODES
Lesson Outcome
At the end of the lesson, students
should be able to describe and
explain:
• Number System: Decimal, Binary, Octal and Hexadecimal Numbers.
• Number Conversion
Decimal to Binary and Binary to Decimal
Binary to Octal and Octal to Binary
Binary to Hexadecimal and Hexadecimal to Binary
• Arithmetic Operation In Binary, Octal and Hexadecimal
• 1st Compliment and 2nd Compliment of Binary Numbers
• Arithmetic Operations with Complements
• Signed Numbers
• Number Codes: BCD, ASCII, Gray and Seven Segment Display
• Parity Method For Error Detection
1.1) NUMBER SYSTEMS
• Decimal number
• Binary number
• Octal number
• Hexadecimal Number
• Symbol : 0, 1 0 0000
1 0001
• Also called base 2 system 2 0010
3 0011
• Commonly used by computer 4 0100
• Each binary digit is called a bit 5 0101
6 0110
• Largest decimal number = 2n-1 7 0111
where n is the no of bits used. 8 1000
9 1001
e.g 8 bits ,largest decimal number 10 1010
= 28-1=255 11 1011
12 1100
13 1101
• e.g. 10102 to show base 2 14 1110
15 1111
LSB 16 10000
MSB
ECE 351 Chapter 1: Number Systems and Codes 11
OCTAL NUMBER
Decimal Octal
Number Number
• Symbol : 0, 1, 2, 3,4, 5, 6, 7 0 0
• Also called base 8 system 1 1
2 2
• Used in computer and micro 3 3
processing application to 4 4
simplify binary representation 5 5
6 6
• Method of grouping binary 7 7
number in groups of 3 8 10
9 11
• e.g. 128
10 12
subscript 8 shows that number 12 is in
11 13
base 8.
12 14
13 15
14 16
15 17
16 20
ECE 351 Chapter 1: Number Systems and Codes 12
HEXADECIMAL
Decimal Octal
NUMBER Number Number
0 0
• Symbol : 0, 1, 2, 3,4, 5, 6, 7,
1 1
8, 9, A, B, C, D, E, F
2 2
• Also called base 16 system 3 3
• Used in computer and micro 4 4
processing application to 5 5
simplify binary representation 6 6
• Method of grouping binary 7 7
number in groups of 4 8 10
• 8 bits = 1 byte 9 11
10 A
• e.g. A716 or A7H 11 B
12 C
13 D
14 E
15 F
16 10
ECE 351 Chapter 1: Number Systems and Codes 13
1.2) NUMBER CONVERSION
2 25 LSB
2 12 1
1) 2510 = ? 2 = 2 6 0
remainders
110012 2 3 0 form the
Answer =
2 1 1 binary
0 1
MSB
2 8 0.4 x 2 = 0.8
LSB
2 4 0 .0011
2 2 0 0.8 x 2 = 1.6
2 1 0 remainders
2 0 1
form the 0.6 x 2 = 1.2
binary
MSB
remainders
8 12 LSB 0.56 x 8 = 4.48
0.48 x 8 = 3.84 .436
8 1 4 0.84 x 8 = 6.72
8 0 1
MSB
Anwer= 14.4368
1) 4728 = > 4 7 2
Answer=1001110102
100 111 010
2) 624.58 = 6 2 4 . 5
Answer=110010100.1012
110 010 100 . 101
2) 100010.12 = 42.48
100010.10
4 2 . 4
0 1
16 204.125
204.12510 = CC.216
16 12 12 = C
0 12 = C
0.125 x 16 = 2 . 0
9 F 2
1) 9F216 = 1001111100102
1001 1111 0010
A . .0 E
2) A.0E16 = 1010.000011102
1010. 0000 1110
178 308
+ 78 - 78
268 218
328 468
+ 78 - 78
418 378
b) Subtraction
A 300
B 28
2D8
ECE 351 Chapter 1: Number Systems and Codes 29
COMPLEMENTS
• 2,s complement is
found by adding 1 to 11100110 1's complement
the LSB of the 1’s
complement
or
leave all LSB ‘0’s and the 11100111 2's complement
1000011 Y
Y-X + 0101011 1's complement of X
1101110 no end carry
1000011 Y
Y-X + 0101100 2's complement of X
1101111 no end carry
• 0 - represent positive
• 1 - represent negative
1010 = 0000 10102
Note: modulo 2 arithmetic: this is binary addition with the carry ignored
1 0 1 1
0 0 1 + + + +
Binary + + + 1 0 1 1 0
0 0 1 0
Gray code 0 0 1 1 1 1 1 0 1
1 1 1 1 0 0 0 1
+ + + + + + + +
Gray code 1 0 0 1 1 1 0 0 1 1
Binary 1 1 1 0 1 0 0 0 1 0
1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US
3 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 @ A B C D E F G H I J K L M N O
5 P Q R S T U V W X Y Z [ \ ] ^ _
6 ` a b c d e f g h i j k l m n o
7 p q r s t u v w x y z { | } ~ •
* The table is DECIMAL (i.e., characters appear normally) but is organized to be read in hexadecimal: Row numbers
[down] represent the first half of a HEX value and column numbers [across] represent the second half of a HEX value.
For example, the uppercase A is located at row 4 and column 1. Therefore, an upper case A in HEX would be 41. Said
another way, if I say "the value is HEX 41" I'm saying the value is uppercase A. But the proper way to write HEX 41 is:
0x41 (65), where "0x" means it's a HEX number, 41 is the row and column [value], and (65) means it is the 65th ASCII
character in the 0-127 list. -- BTW: Lowercase a in HEX is 0x61(98).
55
3. Using 8-bit 2’s complement arithmetic, perform the
following operations, where A=478 and B=7E16.
a) A+B
b) A–B
56