dkt 122 / 3 digital systems 1portal.unimap.edu.my/portal/page/portal30/lecturer notes...decimal...
TRANSCRIPT
DKT 122 / 3DKT 122 / 3DIGITAL SYSTEMS 1DIGITAL SYSTEMS 1
CHAPTER 2 (b) : NUMBER SYSTEMS OPERATION NUMBER SYSTEMS OPERATION
AND CODES [email protected]
[email protected]@ p y
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
SIGN-MAGNITUDE:
Decimal values of +ve & -ve no are Decimal values of +ve & ve no are determined summing the weights in all themag. bit positions where there are 1’s and i i th iti h th ignoring those positions where there are zeros.
The sign is determined by examinationOf the sign bit
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
Sign Magnitudeg g- Determine the decimal value of this signed binary
number expressed in sign-magnitude1001010110010101
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 21The sign bit is 1; dec no is -21
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
1’s COMPLEMENT:
Decimal values of +ve no are determined byysumming the weights in all bit positions wherethere are 1s and ignoring those positions wherethere are zerosthere are zeros.
Decimal number of –ve no are determined byl h h f bassigning a –ve value to the weight of sign bit,
summing all the weights where there are 1s and adding 1 to the resultsg
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
1’s Complement form (example: +ve value)1 s Complement form (example: +ve value)- Determine the decimal value of this signed binary
number expressed in 1’s compliment00010111
-27 26 25 24 23 22 21 20 summing the weight where there is 1s-2 2 2 2 2 2 2 2 g g
0 0 0 1 0 1 1 1 16 + 4 + 2 + 1 = +23
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
1’s Complement form (example: ve value)1 s Complement form (example: -ve value)- Determine the decimal value of this signed binary
number expressed in 1’s complimentp p11101000
-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 = -2424
Adding 1 to the result, the final decimal no isAdding 1 to the result, the final decimal no is-24 + 1 = -23
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
2’S COMPLEMENT:
Decimal values of +ve and ve no are determinedDecimal values of +ve and –ve no are determinedby summing the weights in all by summing theweight in all positions where there are 1s and
h h hignoring those positions where there are zeros
The weight of the sign bit in a –ve no is giveng g ga –ve value
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
2’s Complement form (example: +ve value)p ( p )- Determine the decimal value of this signed binary
number expressed in 1’s compliment01010110
27 26 25 24 23 22 21 20 summing the weight where there is 1s-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
DECIMAL VALUE OF SIGNED NUMBERSDECIMAL VALUE OF SIGNED NUMBERS
2’s Complement form (example: -ve value)p ( p )- Determine the decimal value of this signed binary
number expressed in 1’s compliment10101010
27 26 25 24 23 22 21 20 summing the weight where there is 1s-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
THIS WEEK:THIS WEEK:
• Arithmetic operation with signed numbers• Arithmetic operation with signed numbers• Hexadecimal Numbers• Octal Numbers• Binary Coded Decimal (BCD)• Digital Codes
ARITHMETIC OPERATION WITH SIGNED NOs
Addition:
Conditions:
1.Both number +ve
2. +ve number with magnitude larger than –ve no
b h d l h3.-ve number with magnitude larger than +ve no
4.Both no –ve
ARITHMETIC OPERATION WITH SIGNED NOs
Substraction:
Remember: The sign of a +ve or –ve binary g ynumber is changed by taking its2’s complement
To substract two signed numbers, take the 2’sl f h b h d d ddcomplement of the subtrahend and add.
Discard any final carry bity y
ARITHMETIC OPERATION WITH SIGNED NOsMultiplication:p
2 methods:
• Direct addition – lengthy
2 P i l d 2. Partial product – most common
Partial Product:
Step 1 – determine if the sign of the multiplicandare the same or different That’s willare the same or different. That s willdetermines the end result
If th i th th d t - If the sign are the same, the product = +ve- If the sign are different, the product = -ve
Step 2 – Change any number to uncomplemented form. Usually from2’s complemented form to true numbernumber
Step 3 – Do a partial product multiplication. Useonly the mag bits Ignore sign bitonly the mag. bits. Ignore sign bit
Step 4 – Add each successive partial product to get the final product.
Step 5 – If sign bit is –ve, take the 2’s complementStep 5 If sign bit is ve, take the 2 s complementof the product. Else just leave it as the final result. Don’t forget to add the sign bit
ARITHMETIC OPERATION WITH SIGNED NOsDivision:
Step 1 – determine if the sign of the divident anddivisor are the same or different That’s willdivisor are the same or different. That s willdetermines the sign of the quotient
If th i th th ti t - If the sign are the same, the quotient = +ve- If the sign are different, the quotient = -ve
Step 2 – Substract the divisor from the dividend using 2’s compliment addition to get the 1’s partial remainder and add 1 to quotientpartial remainder and add 1 to quotient
- If the partial remainder is +ve, go to step 3. If –ve,di i i i l t ddivision is completed.
Step 3 – Substract the divisor from the partial remainder and add 1 to quotient. Ifresult = +ve, repeat for the next partialremainder. remainder.
If result = 0 or –ve, division is complete.
0000000000000BinaryOctalHexDec
000000000000000100000010
000001002
012
012
000000110000010000000101
003004005
345
345 00000101
000001100000011100001000
005006007010
5678
5678 00001000
0000100100001010
010011012
89A
8910
000010110000110000001101
013014015
BCD
111213 00001101
0000111000001111
015016017
DEF
131415
Significant DigitsSignificant DigitsSignificant DigitsSignificant DigitsBinary: 11101101Binary: 11101101
Most significant digit Least significant digitMost significant digit Least significant digit
Hexadecimal: 1D63A7AHexadecimal: 1D63A7A
Most significant digit Least significant digitMost significant digit Least significant digit
Hexadecimal Number Hexadecimal Number SystemSystemSystemSystem
• Base 16 system• Base 16 system• Uses digits 0-9 &l tt A B C D E Fletters A,B,C,D,E,F• Groups of four bits
represent eachbase 16 digit
Hexadecimal to Decimal Hexadecimal to Decimal ConversionConversionConversionConversion
Convert 3B4F16 to its decimal equivalent:Convert 3B4F16 to its decimal equivalent:
Hex Digits 3 B 4 Fxxx
163 162 161 160Positional Valuesx
163 162 161 160
12288 +2816 + 64 +15
Positional Values
Products
15,18310
Decimal to Hexadecimal Decimal to Hexadecimal ConversionConversionConversionConversion
Convert 83010 to its hexadecimal equivalent:Convert 83010 to its hexadecimal equivalent:
830 / 16 = 51 R14 = E in Hex830 / 16 = 51 R1451 / 16 = 3 R33 / 16 = 0 R33 / 16 = 0 R3
33E16
Number ConversionNumber Conversion
• Binary to Hexadecimal Conversion (vice versa))
1. Grouping the binary position in 4-bit groups, starting from the least groups, starting from the least significant position.
Binary to Hexadecimal Binary to Hexadecimal C iC iConversionConversion
• The easiest method for converting binary The easiest method for converting binary to hexadecimal is to use a substitution code
• Each hex number converts to 4 binary digits
Number ConversionNumber Conversion
Example:Example:– Convert the following binary numbers to
their hexadecimal equivalent (vice versa)their hexadecimal equivalent (vice versa).a) 10000.12
b) 1F.C16b) 1F.C16
– Answer:a) 10.816) 16
b) 00011111.11002
Substitution CodeSubstitution CodeConvert 0101011010101110011010102 to
Substitution CodeSubstitution CodeConvert 0101011010101110011010102 to
hex using the 4-bit substitution code :
5 6 A E 6 A
0101 0110 1010 1110 0110 1010
56AE6A16
0000000000000BinaryOctalHexDecN
000000000000000100000010
000001002
012
012
UMB 00000011
0000010000000101
003004005
345
345
BER
000001100000011100001000
006007010
678
678
R
S000010000000100100001010
010011012
89A
8910
YST 00001011
0000110000001101
013014015
BCD
111213
TEM
0000111000001111
016017
EF
1415
MS
Octal Number SystemOctal Number SystemOctal Number SystemOctal Number System• Also known as the Base 8 SystemAlso known as the Base 8 System• Uses digits 0 - 7• Readily converts to binary • Readily converts to binary • Groups of three (binary) digits can
be used to represent each octal digitbe used to represent each octal digit• Also uses multiplication and division
algorithms for conversion to and algorithms for conversion to and from base 10
Octal to Decimal Octal to Decimal ConversionConversionConversionConversion
Convert 6538 to its decimal equivalent:
6 5 3xxx
82 81 80Positional Values
Octal Digits
82 81 80
384 + 40 + 3
Positional Values
Products
42710
Decimal to Octal ConversionDecimal to Octal ConversionDecimal to Octal ConversionDecimal to Octal ConversionConvert 42710 to its octal equivalent:Convert 42710 to its octal equivalent:
427 / 8 = 53 R3 Divide by 8; R is LSD427 / 8 53 R3 Divide by 8; R is LSD53 / 8 = 6 R5 Divide Q by 8; R is next digit6 / 8 = 0 R6 Repeat until Q = 0
6538
Number ConversionNumber Conversion
• Binary to Octal Conversion (vice versa)y ( )1. Grouping the binary position in groups
of three starting at the least significant of three starting at the least significant position.
Octal to Binary ConversionOctal to Binary ConversionOctal to Binary ConversionOctal to Binary ConversionEach octal number converts to 3 binary Each octal number converts to 3 binary
digits
To convert 6538 to binary, just substitute code:
6 5 3
110 101 011
Number ConversionNumber Conversion
E lExample:– Convert the following binary numbers to their
octal equivalent (vice versa)octal equivalent (vice versa).a) 1001.11112 b) 47.38
) 1010011 11011c) 1010011.110112
– Answer:) 11 74a) 11.748
b) 100111.0112
c) 123.668
Substitution CodeSubstitution CodeSubstitution CodeSubstitution Code
Substitution code can also be used to convert binary to octal by using 3-bit groupings:
2 5 5 2 7 1 5 2
010 101 101 010 111 001 101 010
255271528
Digital CodesDigital Codes• BCD (Binary Coded Decimal) Code
1. Represent each of the 10 decimal 1. Represent each of the 10 decimal digits (0~9) as a 4-bit binary code.
Example:Example:– Convert 15 to BCD.
1 5
0001 0101 C0001 0101BCD– Convert 10 to binary and BCD.
Digital CodesDigital CodesDigital CodesDigital Codes• ASCII (American Standard Code for
Information Interchange) Codeg )1. Used to translate from the keyboard
characters to computer languagep g g
Digital CodesDigital CodesDigital CodesDigital Codes• The Gray Code Decim Binary Gray The Gray Code
– Only 1 bit changes – Can’t be used in
aly y
Code0 0000 0000
arithmetic circuits• Binary to Gray Code
d i
1 0001 0001
2 0010 0011and vice versa. 2 0010 0011
3 0011 0010
4 0100 01104 0100 0110
5 0101 0111
6 0110 0101