Download presentation
Presentation is loading. Please wait.
Published byQuentin Mathews Modified over 8 years ago
1
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor mohdridzuan@unimap.edu.my 019-3806067 1 DKT 122/3 - DIGITAL SYSTEM I Chapter 2a: Number Systems Operation and Codeds
2
School of Computer and Communication Engineering, UniMAP 2 1.0Number & Codes Digital and analog quantities Decimal numbering system (Base 10) Binary numbering system (Base 2) Hexadecimal numbering system (Base 16) Octal numbering system (Base 8) Number conversion Binary arithmetic 1’s and 2’s complements of binary numbers Signed numbers Arithmetic operations with signed numbers Binary-Coded-Decimal (BCD) Digital codes
3
School of Computer and Communication Engineering, UniMAP Introduction to Numbering Systems 3 We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are: Binary Base 2 Octal Base 8 Hexadecimal Base 16
4
School of Computer and Communication Engineering, UniMAP Number Systems 4 Decimal Binary Octal Hexadecimal 0 ~ 9 0 ~ 1 0 ~ 7 0 ~ F
5
School of Computer and Communication Engineering, UniMAP 5 DECIMAL NUMBERS..10 5 10 4 10 3 10 2 10 1 10 0. 10 -1 10 -2 10 -3
6
School of Computer and Communication Engineering, UniMAP Binary Number System 6 Also called the “Base 2 system” The binary number system is used to model the series of electrical signals computers use to represent information 0 represents the no voltage or an off state 1 represents the presence of voltage or an on state
7
School of Computer and Communication Engineering, UniMAP 7 Binary Numbering Scale Base 2 NumberBase 10 EquivalentPowerPositional Value 00002020 1 00112121 2 01022 4 01132323 8 10042424 16 10152525 32 11062626 64 11172727 128
8
School of Computer and Communication Engineering, UniMAP 8 Figure 2–1 Illustration of a simple binary counting application. Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. COUNTING IN BINARY
9
School of Computer and Communication Engineering, UniMAP 9 EXAMPLE 2-1 Convert the binary whole number 10101101 (base 2) to decimal (base 10)
10
School of Computer and Communication Engineering, UniMAP Binary to Decimal Conversion Convert (10101101) 2 to its decimal equivalent: Binary 1 0 1 0 1 1 0 1 Positional Values x x x xx x x x 2020 21212 2323 2424 2525 2626 2727 128 + 32 + 8 + 4 + 1 Products 173 10
11
School of Computer and Communication Engineering, UniMAP 11 Exercise 2-1 Convert the fractional binary number 0.1011 to decimal
12
School of Computer and Communication Engineering, UniMAP 12 Number Conversion Any Radix (base) to Decimal Conversion
13
School of Computer and Communication Engineering, UniMAP 13 Number Conversion Binary to Decimal Conversion
14
School of Computer and Communication Engineering, UniMAP 14 Number Conversion Sum of weights method Decimal to Any Radix (Base) Conversion 1. INTEGER DIGIT: Repeated division by the radix & record the remainder 2. FRACTIONAL DECIMAL: Multiply the number by the radix until the answer is in integer
15
School of Computer and Communication Engineering, UniMAP 15 Example 2-2 Convert the 25.3125 to Binary
16
School of Computer and Communication Engineering, UniMAP Answer example2.2: - Repeated Division by 2 method 2 5 = 12 + 1 2 1 2 = 6 + 0 2 6 = 3 + 0 2 3 = 1 + 1 2 1 = 0 + 1 2 MSBLSB 25 10 = 1 1 0 0 1 2 Remainder
17
School of Computer and Communication Engineering, UniMAP Answer example2.2: - Fractional Numbers Carry. 0 1 0 1 0.3125 x 2 = 0.625 0 0.625 x 2 = 1.25 1 0.25 x 2 = 0.50 0 0.5 x 2 = 1.00 1 The Answer:.0 1 0 1 MSBLSB
18
School of Computer and Communication Engineering, UniMAP 18 Exercise 2-2 Convert the following decimal numbers (base 10) to Binary (base 2) (a) 19 (b) 45
19
School of Computer and Communication Engineering, UniMAP 19 BINARY ARITHMETIC Binary Addition Binary Substraction Binary Multiplication Binary Division
20
School of Computer and Communication Engineering, UniMAP 20 Binary Addition 0 + 0 = 0Sum of 0 with a carry of 0 0 + 1 = 1Sum of 1 with a carry of 0 1 + 0 = 1 Sum of 1 with a carry of 0 1 + 1 = 10Sum of 0 with a carry of 1 Example: 11001 111 + 1101+ 11 100110 ???
21
School of Computer and Communication Engineering, UniMAP 21 Example 2.3 :- (a) 11 + 11 (b) 100 + 10 (c) 111 + 11 (d) 110 + 100
22
School of Computer and Communication Engineering, UniMAP Binary Subtraction 0 - 0 = 0 1 - 1 = 0 1 - 0 = 1 10 -1 = 10 -1 with a borrow of 1 Example: 1011 101 - 111- 11 100 ???
23
School of Computer and Communication Engineering, UniMAP 23 Binary Subtraction 0 - 0 = 0 1 - 1 = 0 1 - 0 = 1 10 -1 = 10 -1 with a borrow of 1 Example 2.4: 1011 101 - 111- 11 100 ???
24
School of Computer and Communication Engineering, UniMAP 24 Simple Arithmetic Addition Example 2.5: 10001100 2 + 101110 2 10111010 2 Substraction Example 2.6: 1000100 2 - 101110 2 10110 2
25
School of Computer and Communication Engineering, UniMAP 25 Binary Multiplication 0 X 0 = 0 0 X 1 = 0Example 2.7: 1 X 0 = 0100110 1 X 1 = 1 X 101 100110 000000 + 100110 10111110
26
School of Computer and Communication Engineering, UniMAP 26 Binary Division Use the same procedure as decimal division
27
School of Computer and Communication Engineering, UniMAP 1’s complements of binary numbers 27 Changing all the 1s to 0s and all the 0s to 1s Example 2.8: 1 1 0 1 0 0 1 0 1Binary number 0 0 1 0 1 1 0 1 01’s complement
28
School of Computer and Communication Engineering, UniMAP 1’s complements of binary numbers 28 Figure 2–2 Example of inverters used to obtain the 1’s complement of a binary number. Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
29
School of Computer and Communication Engineering, UniMAP 2’s complements of binary numbers 29 2’s complement Example 2.9: Step 1: Find 1’s complement of the number Binary #11000110 1’s complement00111001 Step 2: Add 1 to the 1’s complement 00111001 + 00000001 00111010
30
School of Computer and Communication Engineering, UniMAP 2’s complements of binary numbers 30 Figure 2–3 Example of obtaining the 2’s complement of a negative binary number. Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.
31
School of Computer and Communication Engineering, UniMAP 31 Signed Magnitude Numbers Sign bit 0 = positive 1 = negative 31 bits for magnitude This is your basic Integer format 110010..…00101110010101
32
School of Computer and Communication Engineering, UniMAP Sign numbers 32 Left most is the sign bit 0 is for positive, and 1 is for negative Sign-magnitude form 0 0 0 1 1 0 0 1 = +25 sign bit magnitude bits 1’s complement form The negative number is the 1’s complement of the corresponding positive number Example: +25 is 00011001 -25 is 11100110
33
School of Computer and Communication Engineering, UniMAP Sign numbers 2’s complement form 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 2.10:- Express +19 and -19 in i) sign magnitude ii) 1’s complement iii) 2’s complement
34
School of Computer and Communication Engineering, UniMAP DECIMAL VALUE OF SIGNED NUMBERS Sign Magnitude Example 2.10:- - Determine the decimal value of this signed binary number expressed in sign-magnitude 10010101 2 6 2 5 2 4 2 3 2 2 2 1 2 0 summing the weight where there is 1s 0 0 1 0 1 0 1 16 + 4 + 1 = 21 The sign bit is 1; dec no is -21
35
School of Computer and Communication Engineering, UniMAP DECIMAL VALUE OF SIGNED NUMBERS 1’s Complement form (example: +ve value) Example 2.11 - Determine the decimal value of this signed binary number expressed in 1’s compliment 00010111 -2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 summing the weight where there is 1s 0 0 0 1 0 1 1 1 16 + 4 + 2 + 1 = +23
36
School of Computer and Communication Engineering, UniMAP DECIMAL VALUE OF SIGNED NUMBERS 1’s Complement form (example: -ve value) - Determine the decimal value of this signed binary number expressed in 1’s compliment 11101000 -2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 summing the weight where there is 1s 1 1 1 0 1 0 0 0 -128 + 64 + 32 + 8 = -24 Adding 1 to the result, the final decimal no is -24 + 1 = -23
37
School of Computer and Communication Engineering, UniMAP DECIMAL VALUE OF SIGNED NUMBERS 2’s Complement form (example: +ve value) - Determine the decimal value of this signed binary number expressed in 1’s compliment 01010110 -2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 summing the weight where there is 1s 0 1 0 1 0 1 1 0 64 + 16 + 4 + 2 = +86
38
School of Computer and Communication Engineering, UniMAP DECIMAL VALUE OF SIGNED NUMBERS 2’s Complement form (example: -ve value) Example 2.12 - Determine the decimal value of this signed binary number expressed in 1’s compliment 10101010 -2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 summing the weight where there is 1s 1 0 1 0 1 0 1 0 -128 + 32 + 8 + 2 = -86
39
School of Computer and Communication Engineering, UniMAP 39 Q & A
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.