### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# COMPUTR HRDW FOUNDATNS CSCE 210

GPA 3.61

### View Full Document

## 59

## 0

## Popular in Course

## Popular in Computer Science and Engineering

This 55 page Class Notes was uploaded by Trace Mante MD on Monday October 26, 2015. The Class Notes belongs to CSCE 210 at University of South Carolina - Columbia taught by C. Huang in Fall. Since its upload, it has received 59 views. For similar materials see /class/229583/csce-210-university-of-south-carolina-columbia in Computer Science and Engineering at University of South Carolina - Columbia.

## Reviews for COMPUTR HRDW FOUNDATNS

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/26/15

CSCE 210 iComputer Hardware Foundations ChinTser Huang huanclctcsescedu University of South Carolina Chapter 5 Representing Numerical Data a Number Representation Numbers can be represented as a combination of Value or magnitude Sign plus or minus Decimal fraction if necessary 9152009 Unsigned Numbers Integers Unsigned whole nUmber or integer Direct binay equivalent of decimal integer 4 bits 0 to 9 16 bits 0 to 9999 8 bits 0 to 99 32 bits 0 to 99 999 999 Decimal I Binary I BCD BinaryCoded Decimal 68 0100 0100 0110 1000 262264468 22216 238 99 0110 0011 1001 1001 largest 8bit 26 25 21 20 23 20 23 20 BCD 64322199 9 9 255 1111 1111 0010 0101 0101 39arQeSt 839b39t 28 1 255 21 22 20 22 20 binary 2 5 5 9152009 4 Value Range Binary vs BCD BCD range of values lt conventional binary representation Binary 4 bits can hold 16 different values 0 to 15 BCD 4 bits can hold only 10 different values 0 to 9 No of Bits I BCD Range I Binary Range 4 09 1 digit 015 1 digit 8 099 2 digits 0255 2 digits 12 0999 3 digits 04095 3 digits 16 09999 4 digits 065535 4 digits 20 099999 5 digits 01 million 6 digits 24 0999999 6 digits 016 million 7 digits 32 099999999 8 digits 04 billion 9 digits 64 010161 16 digits 016 quintillion 19 digits 9152009 Conventional Binary vs BCD Binary representation is generally preferred Greater range of value for given number of bits Calculations easier BCD often used in business applications to maintain decimal rounding and decimal precision 9152009 6 Simple BCD Multiplication 76 011Cde convertpartial sumstoB CD X 7 0111bcd 42 gt 101010bm gt 0100 0010M gt110001bin gt 0100 1001bed 41312 gt 010011010010 13 2215 E22113 3204 0001 0011 532 gt 010100110010 532 in BCD 9152009 Packed Decimal Format IBM System 370390 and Compaq Alpha Supported by businessoriented languages like COBOL Most significant digit Sign 1100 or 1101 or 1111 4bits 4bits lt Up to 31 digits 16 bytes gt 9152009 SignedInteger Representation No obvious direct way to represent the sign in binary notation Options Signandmagnitude representation 1 s complement 2 s complement most common 9152009 SignandMagnitude Use leftmost bit for sign 0 plus 1 minus Total range of integers the same Half of integers positive half negative Magnitude of largest integer half as large Example using 8 bits Unsigned 1111 1111 255 Signed 0111 1111 127 1111 1111 127 Note 2 values for 0 0 0000 0000 and 0 1000 0000 9152009 10 V Difficult Calculation Algorithms Signandmagnitude algorithms complex and difficult to implement in hardware Must test for 2 values of O Useful with BCD Order of signed number and carryborrow makes a difference Example Decimal addition algorithm Addition Addition 2 Positive Numbers 1 Signed Number 4 4 2 12 2 39 j j 6 2 2 8 9152009 11 Complementary Representation Sign of the number does not have to be handled separately Consistent for all different signed combinations of input numbers Two methods Radix value used is the base number Diminished radix value used is the base number minus 1 9 s complement base 10 diminished radix 1 s complement base 2 diminished radix 9152009 12 9 s Decimal Complement Takhg the complement subtracting a value from a standard basis value Decimal base 10 system diminished radix complement Radix minus 1 10 1 gt 9 as the basis 3digit example base value 999 Range of possible values 0 to 999 arbitrarily split at 500 Negative Positive Complement Number itself 499 000 0 499 999 minus number none 999 0 499 999 Increasing value 9152009 13 9 s Decimal Complement Necessary to specify number of digits or word size Example representation of 3digit number First digit 0 through 4 gt positive number First digit 5 through 9 gt negative number Conversion to signandmagnitude number for 9 s complement 321 remains 321 521 take the complement 999 521 478 9152009 14 Choice of Representation Must be consistent with rules of normal arithmetic value value If we complement the value twice it should return to its original value Complement basis value Complement twice Basis basis value value 9152009 15 Modular Addition Counting upward on scale corresponds to addition Example in 9 s complement does not cross the modulus 250 l250 Representation 500 649 899 999 0 170 420 499 39 JnTEe39r quotquotquot quot259quot39339572 quotquot quotT137306 quot5quot139772 quotquot quot235165 represented 250 250 9152009 16 Addition with Wraparound Count to the right to add a negative number Wraparound scale used to extend the range for the negative result Counting left would cross the modulus and give incorrect answer because th re are 2 values for 0 0 and O y699 Representation 500 999 0 200 499 500 899 999 Number 499 000 0 200 499 499 100 000 represented 300 Wrong Answer 699 Representation 500 898 999 0 200 499 Number 499 1 01 000 0 200 499 represented 300 9152009 17 Addition with Endaround Carry Count to the right crosses the modulus Endaround carry Add 2 numbers in 9 s complementary arithmetic If the result has more digits than specified add carry to the result 30091099 799 Representation 500 799 999 0 9 499 300 Number 499 200 000 0 100 499 L099 represented 300 1 100 9152009 18 Overflow Fixed word size has a fixed range size Overflow combination of numbers that adds to result outside the range Endaround carry in modular arithmetic avoids problem Complementary arithmetic numbers out of range have the opposite sign Test If both inputs to an addition have the same sign and the output sign is different an overflow occurred 9152009 19 1 s Binary Complement Talking the complement subtracting a value from a standard basis va ue Binary base 2 system diminished radix complement Radix minus 1 2 1 1 as the basis In version Change 119 to 03 and 019 to 15 Numbers beginning with 0 are positive Numbers beginning with 1 are negative 2 values for zero Example with 8bit binary numbers Positive Complement Number itself 127 0 0 127 Inversion None 10000000 11111111 00000000 01111111 9152009 20 Conversion between Complementary Forms Cannot convert directly between 9 s complement and 1 s complement Modulus in 3digit decimal 999 Positive range 499 Modulus in 8bit binary 11111111 or 25510 Positive range 01111111 or 12710 Intermediate step signandmagnitude representation 9152009 21 Examples What is the 9 s complement of the threedigit number 432 567 What is the 9 s complement representation of the threedigit number 432 432 What is the signed value represented by 678 in 9 s complement 321 9152009 22 Addition Add 2 positive 8bit numbers Add 2 8bit number with different sig Take the 1 s complement ie invert C 0011 1010 Invert to get 0000 1101 1100 0101 magnitude 8 4 1 9152009 00101101 45 00111010 58 01100111 103 00101101 45 11000101 58 11110010 13 l 13 23 Addition with Carry 8bit number Invert 0000 0010 210 0110 1010 106 1111 1101 9 bits A 0110 0111 Endaround carry 1 0110 1000 104 9152009 24 Subtraction 8bit number 0110 1010 106 Invert 0101 1010 90194 0101 1010 90 1010 0101 01101010 106 Add 1010 0101 90 9 bits 0000 1111 Endaround carry I gt1 0001 0000 16 9152009 25 Overflow 8bit number i 256 different numbers 0100 0000 64 gagglezgf posrtive numbers 0100 0001 65 I Add q 1000 0001 126 Test for overflow 2 positive inputs 0111 1110 produced negative Invert to get result gt over ow magnitude 12610 Wrong answer Programmers beware some highlevel languages eg some versions of BASIC do not check for overflow adequately 9152009 26 10 s Complement Create complementary system with a single 0 Radix complement use the base for complementary operations Decimal base 10 s complement Example Modulus 1000 as the as reflection point Negative Positive Complement Number itself 500 001 0 499 1000 minus number none 500 999 0 499 9152009 27 Examples with 3Digit Numbers Example 1 10 s complement representation of 247 247 positive number 10 s complement of 247 1000 247 753 753 represents 247 Example 2 10 s complement of 17 1000 017 983 Example 3 10 s complement of 777 We know 777 represents a negative number because first digit is 7 1000 777 223 Signed value represented by 777 223 9152009 28 Alternative Method for 10 s Complement Based on 9 s complement Example using 3digit number Note 1000 999 1 9 s complement 999 value Rewriting 10 s complement 1000 value 999 1 value Or 10 s complement 9 s complement 1 Computationally easier especially when working with binary numbers 9152009 29 2 s Complement Modulus a base 2 1 followed by specified number of 0 s For 8 bits the modulus 1 0000 0000 Two ways to find the complement Subtract value from the modulus or invert Negative Positive Complement Number itself 3912810 39110 010 12710 Inversion None 10000000 11111111 00000000 01111111 9152009 30 Estimating Integer Size Positive numbers begin with 0 Small negative numbers close to 0 begin with multiple 1 s 1111 1110 2 in 8bit 2 s complements 1000 0000 128 largest negative 2 s complements Invert all 1 s and 0 s and approximate the value 9152009 31 Overflow and Carry Conditions Cary flag set when the result of an addition or subtraction exceeds fixed number of bits allocated Overflow result of addition or subtraction overflows into the sign bit 9152009 32 OverflowCarly Examples Example 1 Correct result No overflow no carry Example 2 Incorrect result Overflow no carry 9152009 0100 0010 0110 0100 0110 1010 4 2 6 4 6 6 33 OverflowCarly Examples Example 3 1100 4 Result correct ignoring the 1110 2 carry 11010 6 Carry but no overflow I 1100 4 Example 4 1010 6 Incorrect result 10110 6 Overflow carry ignored 9152009 34 Real Numbers Exponential Notation Also called scienti c notation 12345 12345 X 100 012345 X 105 123450000 X 10394 4 specifications required for a number 1 Sign quot in example 2 Magnitude or mantl39ssa 12345 3 Sign of the exponent quot in 105 4 Magnitude of the exponent 5 I PIUS 5 Base of the exponent 10 e Location of decimal point or other base radix point 9152009 35 Summary of Rules Sign of the mantissa Sign of the exponent 035790 x 106 LocationMantissa B se Exponent of decimal point 9152009 36 Format Specification Predefined format usually in 8 digits Increased range of values two digits of exponent traded for decreased precision two digits of mantissa Sign ol the mantissa SEEMMMMM 2digit Exponent 5digit Mantissa 9152009 37 Format Mantissa sign digit in signmagnitude format Assume decimal point located at beginning of mantissa Exponent excessN notation Pick middle value as offset where N is the middle value Representation 4 i0 Exponent being represented 50 1 0 49 Increasing value L r 9152009 38 Overflow and Underflow Possible for the number to be too large or too small for representation o99999 x 1049 4355 1955 099999 x 1049 O 39 l ll l l 39 Overflow Underflow Overflow region region region 9152009 39 Conversion Examples 05324567 024567X 103 54810000 010000 X 10392 55555555 055555 X 105 04925000 025000 X 10391 9152009 24567 00010000 55555 0025000 40 Normalization Shift numbers left by decreasing the exponent until leading zeros eliminated Converting decimal number into standard format 1 Provide number with exponent 0 if not yet specified 2 Increasedecrease exponent to shift decimal point to proper position 3 Decrease exponent to eliminate leading zeros on mantissa 4 Correct precision by adding 0 s or discardingrounding least significant digits 9152009 41 Example 1 2468035 1 Add exponent 7 2 Position decimal point 3 Already normalized 4 Cut to 5 digits 5 Convert number Sign Excess50 exponent 2468035 X 100 2468035 X 103 24680 X 103 9152009 Mantissa 05324680 I 42 Example 2 000000075 1 Exponential notation 000000075 X 100 2 Decimal point in position 3 Normalizing 075 X 10396 4 Add 0 for 5 digits 075000 X 10396 5 Convert number 54475000 9152009 43 Floating Point Calculations Addition and subtraction Exponent and mantissa treated separately Exponents of numbers must agree Align decimal points Least significant digits may be lost Mantissa overflow requires exponent again shifted right 9152009 44 Addition and Subtraction Add 2 floating point numbers 05199520 04967850 Align exponents 05199520 0510067850 Add mantissas 1 indicates a carry 10019850 Carry requires right shift 05210019850 Round 05210020 Check results 05199520 099520 x 101 99520 04967850 067850 x 10391 M 1001985 In exponential form 01001985 X 102 9152009 45 Multiplication and Division Mantissas multiplied or divided Exponents added or subtracted Normalization necessary to Restore location of decimal point Maintain precision of the result Adjust excess value since added twice Example 2 numbers with exponent 3 represented in excess50 notation 53 53 106 Since 50 added twice subtract 106 50 56 9152009 46 Multiplication and Division Maintaining precision Normalizing and rounding multiplication a Multiply 2 numbers 05220000 x 04712500 a Add exponents subtract offset 52 47 50 49 a Multiply mantissas 020000 x 012500 0025000000 a Normalize the results 04825000 a Round No round off needed a Check results 05220000 020000 x 102 04712500 0125 x 10393 00250000000 x 10391 a Normalizing and rounding 025000 x 10392 9152009 47 Floating Point in the Computer Typical floating point format 32 bits provide range 103938 to 1038 8bit exponent 256 levels Excess128 notation 2324 bits of mantissa approximately 7 decimal digits of precision bit gt0 1 8 9 31 S E E M M msb lsb Sign of Mantissa mantissa Excess128 exponent 9152009 48 V Floating Point in the Computer Assume excess128 exponent Sign of mantissa Mantissa 0 1000 0001 1100 1100 0000 0000 0000 000 11001 1000 0000 0000 00 1 1000 0100 1000 0111 1000 0000 0000 000 10000111 1000 0000 0000 000 1 0111 1110 1010 1010 1010 1010 10101 101 00010 1010 1010 1010 1010 1 9152009 49 IEEE 754 Standard Sign 1 bit 1 bit Exponent 8 bits 11 bits Notation Excess127 Excess1023 Implied base 2 2 Range 2126 to 2127 21022 to 21023 Mantissa 23 52 Decimal digits z 7 z 15 Value range m 103945 to 1038 z 1039300 to 10300 9152009 50 IEEE 754 Standard 32bit Floating Point Value Definition Exponent Mantissa Value 7 0 0 0 0 Not 0 i239126x OM 1254 Any 1212642 x 1M 255 0 too 255 not 0 special condition Numbers are normalized to the form 1MMM Leading 1 is not stored but implied 9152009 51 g Conversion Base 10 and Base 2 Two steps Whole and fractional parts of numbers with an embedded decimal or binary point must be converted separately Numbers in exponential form must be reduced to a pure decimal or binary mixed number or fraction before the conversion can be performed 9152009 52 Conversion Base 10 and Base 2 Convert 2537510 to binary floating point form Convert to binary 1111110111 equivalent or 1111110111 x 27 IEEE RepresentationO 1000Q110 11111011100 Excess127 Mantissa 8399quot Exponent 127 7 9152009 53 Programming Considerations Integer advantages Easier for computer to perform Potential for higher precision Faster to execute Fewer storage locations to save time and space Most highlevel languages provide 2 or more formats Short integer 16 bits Long integer 64 bits 9152009 54 Programming Considerations Real numbers Variable or constant has fractional part Numbers take on very large or very small values outside integer range Program should use least precision sufficient for the task Packed decimal is an attractive alternative for business applications 9152009 55

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

#### "When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the material...plus I made $280 on my first study guide!"

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.