Escolar Documentos
Profissional Documentos
Cultura Documentos
NUMBER SYSTEMS
& CODES
DIGITAL SYSTEM 1
ECE 351
1.1) NUMBER SYSTEMS
Decimal number
Binary number
Octal number
Hexadecimal Number
DECIMAL NUMBER 0
1
2
Symbol : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9… 3
Also called base 10 system or radix of 10 4
e.g. 1210 subscript 10 shows that number 5
6
in base 10.
7
Commonly used in human daily activities. 8
9
10
11
12
13
14
15
16
BINARY NUMBER 0 0
1 1
2 10
Symbol : 0, 1 3 11
Also called base 2 system 4 100
5 101
Commonly used by computer 6 110
Each binary digit is called a bit 7 111
8 1000
Largest decimal number = 2n-1 9 1001
where n is the no of bits used. 10 1010
e.g 8 bits ,largest decimal number 11 1011
12 1100
= 28-1=255
13 1101
14 1110
e.g. 10102 to show base 2 15 1111
16 1 0 0 0 0 0
LSB
ECE 351 MSB Chapter 1: Number Systems and Codes 4
OCTAL NUMBER Decimal
0
Octal
0
1 1
Symbol : 0, 1, 2, 3,4, 5, 6, 7 2 2
Also called base 8 system 3 3
4 4
Used in computer and micro 5 5
processing application to 6 6
simplify binary representation 7 7
Method of grouping binary 8 10
number in groups of 3 9 11
10 12
e.g. 128 11 13
subscript 8 shows that number 12 is in
12 14
base 8.
13 15
14 16
15 17
ECE 351 Chapter 1: Number Systems and Codes
16 20 5
HEXADECIMAL
NUMBER Decimal Hexadecimal
0 0
1 1
Symbol : 0, 1, 2, 3,4, 5, 6, 7, 2 2
8, 9, A, B, C, D, E, F
3 3
Also called base 16 system 4 4
Used in computer and micro 5 5
processing application to 6 6
simplify binary representation
7 7
Method of grouping binary 8 8
number in groups of 4
9 9
8 bits = 1 byte 10 A
e.g. A716 or A7H 11 B
12 C
13 D
14 E
15 F
ECE 351 Chapter 1: Number Systems and Codes 6
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
LSB 0.2 x 2 = 0.4 0.0
2 4 0
0.4 x 2 = 0.8 0.00
2 2 0
0.8 x 2 = 1.6 0.001
remainders
2 1 0
form the 0.6 x 2 = 1.2 0.0011
2 0 1
binary
MSB
remainders
8 12 LSB 0.56 x 8 = 4.48 0.4
0.48 x 8 = 3.84 0.43
8 1 4 0.84 x 8 = 6.72 0.436
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
0 1
16 204.125
204.12510 = CC.216
16 12 12 = C
0 12 = C
0.125 x 16 = 2 . 0
ECE 351 Chapter 1: Number Systems and Codes 15
NUMBER CONVERSIONS (Cont’d)
5a) Hexadecimal Binary
Convert each hex digit to its 4-bit binary equivalent
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 22
1’s and 2’s COMPLEMENT OF
BINARY NUMBERS
1’s complement of a
binary number is found
by changing all 1s to
0s and all 0s to 1s 00011001 Binary number
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
00011001
Magnitude bits
•1’s complement
•2’s complement
1000011 Y
Y-X + 0101011 1's complement of X
1101110
-0010001 answer
1000011 Y
Y-X + 0101100 2's complement of X
1101111
-0010001 answer
BCD (binary-coded-decimal)
- weighted code
- also known as 8421 BCD code
- is used to represent each of 10 decimal digits as a 4-bit binary
code
- convert each decimal digit to its 4-bit binary code
- only 0000 ~ 1001 are used.
- BCD code does not use numbers 1010, 1011, 1100, 1101, 1110,
1111
- BCD is not a straight binary number
decimal 8 7 4
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
ECE 351 Chapter 1: Number Systems and Codes 37
NUMBER CODES (cont’d)
Gray to Binary conversion
i. Write down the number in gray code
ii. The MSB of binary is the MSB of Gray code
iii. Add (using modulo 2) the next significant bit of the binary number
to the next significant bit of the Gray code to obtain the next bit
iv. Continue step ‘iii’ right through the end
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(97).