School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter 2b: Number Systems Operation and Codeds
School of Computer and Communication Engineering, UniMAP 2 SIGN-MAGNITUDE: Decimal values of +ve & -ve no are determined summing the weights in all the mag. bit positions where there are 1’s and ignoring those positions where there are zeros. The sign is determined by examination Of the sign bit DECIMAL VALUE OF SIGNED NUMBERS
School of Computer and Communication Engineering, UniMAP 3 DECIMAL VALUE OF SIGNED NUMBERS Sign Magnitude - Determine the decimal value of this signed binary number expressed in sign-magnitude summing the weight where there is 1s = 21 The sign bit is 1; dec no is -21
School of Computer and Communication Engineering, UniMAP 4 DECIMAL VALUE OF SIGNED NUMBERS 1’s COMPLEMENT: Decimal values of +ve no are determined by summing the weights in all bit positions where there are 1s and ignoring those positions where there are zeros. Decimal number of –ve no are determined by assigning a –ve value to the weight of sign bit, summing all the weights where there are 1s and adding 1 to the results
School of Computer and Communication Engineering, UniMAP 5 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 summing the weight where there is 1s = +23
School of Computer and Communication Engineering, UniMAP 6 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 summing the weight where there is 1s = -24 Adding 1 to the result, the final decimal no is = -23
School of Computer and Communication Engineering, UniMAP 7 DECIMAL VALUE OF SIGNED NUMBERS 2’S COMPLEMENT: Decimal values of +ve and –ve no are determined by summing the weights in all by summing the weight in all positions where there are 1s and ignoring those positions where there are zeros The weight of the sign bit in a –ve no is given a –ve value
School of Computer and Communication Engineering, UniMAP 8 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 summing the weight where there is 1s = +86
School of Computer and Communication Engineering, UniMAP 9 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 summing the weight where there is 1s = -86
School of Computer and Communication Engineering, UniMAP 10 ARITHMETIC OPERATION WITH SIGNED NOs Addition: Conditions: 1.Both number +ve 2. +ve number with magnitude larger than –ve no 3.-ve number with magnitude larger than +ve no 4.Both no –ve
School of Computer and Communication Engineering, UniMAP 11 ARITHMETIC OPERATION WITH SIGNED NOs Substraction: Remember: The sign of a +ve or –ve binary number is changed by taking its 2’s complement To substract two signed numbers, take the 2’s complement of the subtrahend and add. Discard any final carry bit
School of Computer and Communication Engineering, UniMAP 12 ARITHMETIC OPERATION WITH SIGNED NOs Multiplication: 2 methods: Direct addition – lengthy 2. Partial product – most common Partial Product: Step 1 – determine if the sign of the multiplicand are the same or different. That’s will determines the end result -If the sign are the same, the product = +ve -If the sign are different, the product = -ve
School of Computer and Communication Engineering, UniMAP 13 Step 2 – Change any number to uncomplemented form. Usually from 2’s complemented form to true number Step 3 – Do a partial product multiplication. Use only 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 complement of the product. Else just leave it as the final result. Don’t forget to add the sign bit
School of Computer and Communication Engineering, UniMAP 14 ARITHMETIC OPERATION WITH SIGNED NOs Division: Step 1 – determine if the sign of the divident and divisor are the same or different. That’s will determines the sign of the quotient -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 quotient -If the partial remainder is +ve, go to step 3. If –ve, division is completed.
School of Computer and Communication Engineering, UniMAP 15 Step 3 – Substract the divisor from the partial remainder and add 1 to quotient. If result = +ve, repeat for the next partial remainder. If result = 0 or –ve, division is complete. ARITHMETIC OPERATION WITH SIGNED NOs
School of Computer and Communication Engineering, UniMAP ABCDEF ABCDEF BinaryOctalHexDec
School of Computer and Communication Engineering, UniMAP 17 Significant Digits Binary: Most significant digit Least significant digit Hexadecimal: 1D63A7A Most significant digit Least significant digit
School of Computer and Communication Engineering, UniMAP 18 Hexadecimal Number System Base 16 system Uses digits 0-9 & letters A,B,C,D,E,F Groups of four bits represent each base 16 digit
School of Computer and Communication Engineering, UniMAP 19 Hexadecimal to Decimal Conversion Convert 3B4F 16 to its decimal equivalent: Hex Digits 3 B 4 F xx x , Positional Values Products x
School of Computer and Communication Engineering, UniMAP 20 Decimal to Hexadecimal Conversion Convert to its hexadecimal equivalent: 830 / 16 = 51 R14 51 / 16 = 3 R3 3 / 16 = 0 R3 33E 16 = E in Hex
School of Computer and Communication Engineering, UniMAP 21 Number Conversion Binary to Hexadecimal Conversion (vice versa) 1. Grouping the binary position in 4-bit groups, starting from the least significant position.
School of Computer and Communication Engineering, UniMAP 22 Binary to Hexadecimal Conversion The easiest method for converting binary to hexadecimal is to use a substitution code Each hex number converts to 4 binary digits
School of Computer and Communication Engineering, UniMAP 23 Number Conversion Example: Convert the following binary numbers to their hexadecimal equivalent (vice versa). a) b) 1F.C 16 Answer: a) b) or
School of Computer and Communication Engineering, UniMAP 24 Convert to hex using the 4-bit substitution code : Substitution Code 5 6 A E 6 A 56AE6A 16
School of Computer and Communication Engineering, UniMAP ABCDEF ABCDEF BinaryOctalHexDec NUMBER SYSTEMSNUMBER SYSTEMS
School of Computer and Communication Engineering, UniMAP 26 Octal Number System Also known as the Base 8 System Uses digits Readily converts to binary Groups of three (binary) digits can be used to represent each octal digit Also uses multiplication and division algorithms for conversion to and from base 10
School of Computer and Communication Engineering, UniMAP 27 Octal to Decimal Conversion Convert to its decimal equivalent: xx x Positional Values Products Octal Digits
School of Computer and Communication Engineering, UniMAP 28 Decimal to Octal Conversion Convert to its octal equivalent: 427 / 8 = 53 R3Divide by 8; R is LSD 53 / 8 = 6 R5Divide Q by 8; R is next digit 6 / 8 = 0 R6Repeat until Q =
School of Computer and Communication Engineering, UniMAP 29 Number Conversion Binary to Octal Conversion (vice versa) 1. Grouping the binary position in groups of three starting at the least significant position.
School of Computer and Communication Engineering, UniMAP 30 Octal to Binary Conversion Each octal number converts to 3 binary digits To convert to binary, just substitute code:
School of Computer and Communication Engineering, UniMAP 31 Number Conversion Example: Convert the following binary numbers to their octal equivalent (vice versa). a) b) c) Answer: a) b) c)
School of Computer and Communication Engineering, UniMAP 32 Substitution code can also be used to convert binary to octal by using 3-bit groupings: Substitution Code
School of Computer and Communication Engineering, UniMAP 33 Digital Codes BCD (Binary Coded Decimal) Code 1. Represent each of the 10 decimal digits (0~9) as a 4-bit binary code. Example: Convert 15 to BCD BCD Convert 10 to binary and BCD.
School of Computer and Communication Engineering, UniMAP 34 Digital Codes ASCII (American Standard Code for Information Interchange) Code 1. Used to translate from the keyboard characters to computer language
School of Computer and Communication Engineering, UniMAP 35 Digital Codes The Gray Code Only 1 bit changes Can’t be used in arithmetic circuits Binary to Gray Code and vice versa. DecimalBinaryGray Code
School of Computer and Communication Engineering, UniMAP 36 Q & A