Click here to load reader

School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor [email protected] 019-3806067 1 DKT 122/3 - DIGITAL SYSTEM I Chapter

Embed Size (px)

Citation preview

DKT 212 / 3 DIGITAL SYSTEM II

Mohd ridzuan mohd [email protected] 122/3 - DIGITAL SYSTEM IChapter 2a: Number Systems Operation and CodedsSchool of Computer and Communication Engineering, UniMAP1mrar200921.0Number & CodesDigital and analog quantitiesDecimal numbering system (Base 10)Binary numbering system (Base 2)Hexadecimal numbering system (Base 16)Octal numbering system (Base 8)Number conversionBinary arithmetic1s and 2s complements of binary numbersSigned numbersArithmetic operations with signed numbersBinary-Coded-Decimal (BCD)Digital codes School of Computer and Communication Engineering, UniMAPIntroduction to Numbering Systems3We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are:

Binary Base 2Octal Base 8Hexadecimal Base 16

School of Computer and Communication Engineering, UniMAPNumber Systems4DecimalBinary Octal Hexadecimal

0 ~ 90 ~ 1 0 ~ 70 ~ FSchool of Computer and Communication Engineering, UniMAP5DECIMAL NUMBERS

..105 104 103 102 101 100 . 10-1 10-2 10-3School of Computer and Communication Engineering, UniMAPBinary Number System6Also called the Base 2 systemThe 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 state1 represents the presence of voltage or an on stateSchool of Computer and Communication Engineering, UniMAP7Binary Numbering ScaleBase 2 NumberBase 10 EquivalentPowerPositional Value0000201001121201022240113238100424161015253211062664111727128School of Computer and Communication Engineering, UniMAP8Figure 21 Illustration of a simple binary counting application. Copyright 2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458All rights reserved.

COUNTING IN BINARYSchool of Computer and Communication Engineering, UniMAP9EXAMPLE 2-1

Convert the binary whole number10101101 (base 2) to decimal (base 10)School of Computer and Communication Engineering, UniMAPBinary to Decimal ConversionConvert (10101101)2 to its decimal equivalent:

Binary 1 0 1 0 1 1 0 1

Positional Valuesxxxxxxxx2021222324252627128 + 32 + 8 + 4 + 1Products17310School of Computer and Communication Engineering, UniMAP1011Exercise 2-1

Convert the fractional binary number0.1011 to decimalSchool of Computer and Communication Engineering, UniMAP12Number ConversionAny Radix (base) to Decimal Conversion

School of Computer and Communication Engineering, UniMAP13Number ConversionBinary to Decimal Conversion

School of Computer and Communication Engineering, UniMAP14Number ConversionSum of weights methodDecimal to Any Radix (Base) ConversionINTEGER DIGIT: Repeated division by the radix & record the remainderFRACTIONAL DECIMAL:Multiply the number by the radix until the answer is in integerSchool of Computer and Communication Engineering, UniMAP15Example 2-2

Convert the 25.3125 to Binary School of Computer and Communication Engineering, UniMAPAnswer example2.2:- Repeated Division by 2 method2 5 = 12 + 1 2

1 2 = 6 + 0 2

6 = 3 + 0 2

3 = 1 + 1 2

1 = 0 + 1 2 MSBLSB 2510 = 1 1 0 0 1 2RemainderSchool of Computer and Communication Engineering, UniMAP16Answer example2.2: - Fractional Numbers Carry . 0 1 0 10.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 1MSBLSBSchool of Computer and Communication Engineering, UniMAP1718Exercise 2-2

Convert the following decimal numbers (base 10) toBinary (base 2)

(a) 19 (b) 45

School of Computer and Communication Engineering, UniMAP19BINARY ARITHMETIC

Binary Addition

Binary Substraction

Binary Multiplication

Binary DivisionSchool of Computer and Communication Engineering, UniMAP20Binary Addition0 + 0 = 0Sum of 0 with a carry of 00 + 1 = 1Sum of 1 with a carry of 01 + 0 = 1 Sum of 1 with a carry of 01 + 1 = 10Sum of 0 with a carry of 1Example: 11001 111 + 1101+ 11 100110 ???School of Computer and Communication Engineering, UniMAP21Example 2.3 :-

(a) 11 + 11

(b) 100 + 10

(c) 111 + 11

(d) 110 + 100School of Computer and Communication Engineering, UniMAPBinary Subtraction 0 - 0 = 0 1 - 1 = 0 1 - 0 = 110 -1 = 10 -1 with a borrow of 1Example:1011 101 - 111- 11 100 ???School of Computer and Communication Engineering, UniMAP2223Binary Subtraction 0 - 0 = 0 1 - 1 = 0 1 - 0 = 110 -1 = 10 -1 with a borrow of 1Example 2.4:1011 101 - 111- 11 100 ???School of Computer and Communication Engineering, UniMAP24Simple ArithmeticAdditionExample 2.5: 100011002 + 1011102 101110102

SubstractionExample 2.6: 10001002 - 1011102 101102School of Computer and Communication Engineering, UniMAP25Binary Multiplication0 X 0 = 00 X 1 = 0Example 2.7:1 X 0 = 01001101 X 1 = 1 X 101100110 000000 + 100110 10111110School of Computer and Communication Engineering, UniMAP26Binary DivisionUse the same procedure as decimal division

School of Computer and Communication Engineering, UniMAP1s complements of binary numbers27Changing 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 01s complementSchool of Computer and Communication Engineering, UniMAP1s complements of binary numbers28Figure 22 Example of inverters used to obtain the 1s complement of a binary number. Copyright 2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458All rights reserved.

School of Computer and Communication Engineering, UniMAP2s complements of binary numbers292s complementExample 2.9:Step 1: Find 1s complement of the numberBinary #110001101s complement00111001Step 2: Add 1 to the 1s complement00111001 + 0000000100111010

School of Computer and Communication Engineering, UniMAP2s complements of binary numbers30Figure 23 Example of obtaining the 2s complement of a negative binary number. Copyright 2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458All rights reserved.

School of Computer and Communication Engineering, UniMAP31Signed Magnitude NumbersSign bit0 = positive1 = negative31 bits for magnitudeThis is your basic Integer format110010..00101110010101School of Computer and Communication Engineering, UniMAPSign numbers32Left most is the sign bit 0 is for positive, and 1 is for negativeSign-magnitude form 0 0 0 1 1 0 0 1 = +25

sign bit magnitude bits

1s complement formThe negative number is the 1s complement of the corresponding positive numberExample: +25 is 00011001 -25 is 11100110School of Computer and Communication Engineering, UniMAPSign numbers2s complement formThe positive number same as sign magnitude and 1s complementThe negative number is the 2s complement of the corresponding positive number.Example 2.10:- Express +19 and -19 ini) sign magnitudeii) 1s complementiii) 2s complementSchool of Computer and Communication Engineering, UniMAP33DECIMAL VALUE OF SIGNED NUMBERSSign MagnitudeExample 2.10:-Determine the decimal value of this signed binary number expressed in sign-magnitude 10010101

26 25 24 23 22 21 20 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

School of Computer and Communication Engineering, UniMAP34DECIMAL VALUE OF SIGNED NUMBERS1s Complement form (example: +ve value)Example 2.11Determine the decimal value of this signed binary number expressed in 1s compliment 00010111

-27 26 25 24 23 22 21 20 summing the weight where there is 1s 0 0 0 1 0 1 1 1 16 + 4 + 2 + 1 = +23 School of Computer and Communication Engineering, UniMAP35DECIMAL VALUE OF SIGNED NUMBERS1s Complement form (example: -ve value)Determine the decimal value of this signed binary number expressed in 1s compliment 11101000

-27 26 25 24 23 22 21 20 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

School of Computer and Communication Engineering, UniMAP36DECIMAL VALUE OF SIGNED NUMBERS2s Complement form (example: +ve value)Determine the decimal value of this signed binary number expressed in 1s compliment 01010110

-27 26 25 24 23 22 21 20 summing the weight where there is 1s 0 1 0 1 0 1 1 0 64 + 16 + 4 + 2 = +86

School of Computer and Communication Engineering, UniMAP37DECIMAL VALUE OF SIGNED NUMBERS2s Complement form (example: -ve value)Example 2.12Determine the decimal value of this signed binary number expressed in 1s compliment 10101010

-27 26 25 24 23 22 21 20 summing the weight where there is 1s 1 0 1 0 1 0 1 0 -128 + 32 + 8 + 2 = -86

School of Computer and Communication Engineering, UniMAP3839Q & ASchool of Computer and Communication Engineering, UniMAP