PLT 106 DIGITAL ELECTRONICS CHAPTER 2 NUMBER SYSTEM
PLT 106 DIGITAL ELECTRONICS CHAPTER 2 NUMBER SYSTEM, OPERATIONS AND CODES EN KHAIRUL ANUAR BIN MOHD NOR 1
Number Systems & Codes v Introduction to number systems – – Decimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary (Base 2) 0, 1 Octal (Base 8) 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal(Base 16) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F v Number Conversion v Simple Arithmetic v Binary Codes 2
N U M B E R S Y S T E M DEC HEX OCTAL BINARY 0 0 00000 1 1 00001 2 2 00010 3 3 00011 4 4 00100 5 5 00101 6 6 00110 7 7 00111 8 8 01000 9 9 011 01001 10 A 012 01010 11 B 013 01011 12 C 014 01100 13 D 015 01101 14 E 016 01110 15 F 017 01111 3
Decimal Number Positional Values MSB = Most Significant Bit LSB = Least Significant Bit Try>>> 4710 4
Binary Number 5
Binary to decimal conversion 6
Binary to decimal conversion 7
Decimal to binary conversion Two ways to convert a decimal number to binary number: 1. using sum of weights method 2. using the repeated division by 2 8
Decimal to binary conversion Try>> 5810 9
Decimal to binary conversion Try>> 5810 10
Converting decimal fractions to Binary Two ways to convert a decimal fractions number to binary number: 1. using sum of weights method 2. using the repeated multiplication by 2 11
Converting decimal fractions to Binary Example : - Convert the decimal number 0. 625 to binary using Sum of Weight and multiplication by 2 method Sum of weight --- 0. 625 = 0. 5 +0. 125 = 2 -1+2 -3 0 . 2 -1 = 0. 5 2 -2= 0. 25 2 -3= 0. 125 . 1 0 1 Multiplication by 2 --0. 625 x 2 = 1. 25 0. 25 x 2 = 0. 5 x 2 = 1. 0 0 x 2=0 1 0 Try>> 0. 18810 0. 1012 12
Hex to Decimal conversion Try >> 1 C 16 & A 8516 13
Decimal to Hex conversion Try>>> 65010 to hex 14
Hex to binary conversion 15
Binary to Hex conversion 16
Binary to Octal conversion (vise versa) • Grouping the binary position in groups of three starting at the least significant position. • Example: Convert the following binary numbers to their octal equivalent (vice versa) 001 010 011 110 100 111 011 17
Binary Arithmetic BINARY ADDITION The rules for binary addition are 0+0=0 Sum = 0, carry = 0 0+1=1 Sum = 1, carry = 0 1+0=1 Sum = 1, carry = 0 1+1=0 Sum = 0, carry = 1 When an input carry = 1 due to a previous result, the rules are 1 + 0 = 01 Sum = 1, carry = 0 1 + 0 + 1 = 10 Sum = 0, carry = 1 1 + 0 = 10 Sum = 0, carry = 1 1 + 1 = 11 Sum = 1, carry = 1 TRY>> a) 11 + 11 b) 110 + 100 18
Binary Arithmetic BINARY SUBTRACTION The 4 basic rules for subtracting bits are follows: 0– 0=0 1– 1=0 1– 0=1 10 – 1 = 1 with a borrow of 1 TRY>> a) 11 -01 b) 10101 -00111 19
Binary Arithmetic BINARY MULTIPLICATION • • 0 X 0=0 0 X 1=0 1 X 0=0 1 X 1=1 Example: 100110 101 100110 000000 100110 10111110 20
Binary Arithmetic BINARY DIVISION • Use the same procedure as decimal division. • Example: Perform the following binary division. 10 2 11 3 11 000 6 0 10 10 10 00 6 0 21
1’s Complement 22
2’s Complement 23
Signed Numbers • Left most is the sign bit 0 is for positive, and 1 is for negative. • Sign-magnitude 00011001 = + 25 Sign bit Magnitude bits 1’s complement – The negative number is the 1’s complement of the corresponding positive number. – Example: +25 is 00011001 -25 is 11100110 24
Signed Numbers 2’s complement – The positive number – same as sign magnitude and 1’s complement. – The negative number is the 2’s complement of the corresponding positive number. • Example: Express +19 and -19 in sign magnitude, 1’s complement and 2’s complement. Sign Magnitude 1’s Complement 2’s Complement TRY >> +39 & -39 +19 00010011 -19 10010011 11101100 11101101 25
Arithmetic Operations with Signed Numbers 26
Arithmetic Operations with Signed Numbers 27
Binary Coded Decimal (BCD) 28
BCD Example: Convert each of the following decimal number to BCD b) 170 Convert each of the following BCD codes to decimal a) 10000110 29
BCD Addition Step: 1. Add the two BCD numbers, using the rules for binary addition 2. If a 4 bit sum is equal to or less than 9, it is a valid BCD number 3. If a 4 bit sum is greater than 9, or if a carry out of the 4 bit is generated, it is an invalid result. Add 6 (0110) to the for 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. 30
BCD Addition Example: Add the following BCD numbers a) 0011 + 0100 b) 1001 + 0100 c) 10000110 + 00010011 d) 01100111 + 01010011 e) 00010110 + 00010101 31
THE END 32
- Slides: 32