DOC PREVIEW
RU CS 208 - Signed Numbers

This preview shows page 1-2-3-4-28-29-30-31-57-58-59-60 out of 60 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Signed NumbersSlide 2Sign/Magnitude RepresentationSlide 4Slide 5Slide 6Slide 7Slide 8Try It YourselfAnswersProblems with Sign/MagnitudeTwo’s Complement RepresentationSlide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Two’s Complement to DecimalSlide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39S/M problems solved with 2s complementSlide 41Slide 42Twos Complement RepresentationSlide 44AnswerSlide 46Valid RangesUnsigned Integer RangesSlide 49Signed S/M Integer RangesS/M Integer RangesTwo’s Complement RangesSlide 53Slide 54Slide 55Using Ranges for Validity CheckingSlide 57Slide 58Slide 59Slide 60Signed NumbersCS208Signed NumbersUntil now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers ( like: -12, -45, +78). A signed number MUST have a sign (+/-). A method is needed to represent the sign as part of the binary representation. Two signed number representation methods are:Sign/magnitude representationTwos-complement representationSign/Magnitude RepresentationIn sign/magnitude (S/M) representation, the leftmost bit of a binary code represents the sign of the value: 0 for positive, 1 for negative; The remaining bits represent the numeric value.Sign/Magnitude RepresentationTo compute negative values using Sign/Magnitude (S/M) representation:1) Begin with the binary representation of the positive value2) Then flip the leftmost zero bit.Sign/Magnitude Representation Ex 1. Find the S/M representation of -610 So: -610 = 100001102 (in 8-bit sign/magnitude form) Step 2: If the number you want to represent is negative, flip leftmost bit 10000110 Step 1: Find binary representation using 8 bits 610 = 000001102Sign/Magnitude Representation Ex 2. Find the S/M representation of 7010 Step 2: If the number you want to represent isnegative, flip left most bit 01000110 (positive -- no flipping) Step 1: Find binary representation using 8 bits 7010 = 010001102 So: 7010 = 010001102 (in 8-bit sign/magnitude form)Sign/Magnitude Representation Ex 3. Find the S/M representation of -3610 Step 2: If the number you want to represent isnegative, flip left most bit 10100100 Step 1: Find binary representation using 8 bits -3610 = 001001002 So: -3610 = 101001002 (in 8-bit sign/magnitude form)Sign bit: 0  positive 1  negativeSign bit: 0  positive 1  negative31 remaining bits for magnitude (i.e. the value)31 remaining bits for magnitude (i.e. the value)32-bit example:0 000 0000 0000 0000 0000 0000 0000 10011 000 0000 0000 0000 0000 0000 0000 1001+9-9Sign/Magnitude RepresentationTry It YourselfConvert the following decimal numbers to 8-bit sign/magnitude representation:35-60-101(Answers on NEXT slide)Answers35 = 00100011-60 = 10111100-101 = 11100101• Two different representations for 0!0000011100111011111111101101110010101001100001100101010000100001+0+1+2+3+4+5+6+7-0-1-2-3-4-5-6-7Inner numbers:Binary representationSeven Positive Numbers and “Positive” ZeroSeven Negative Numbers and “Negative” Zero• Two discontinuitiesProblems with Sign/MagnitudeTwo’s Complement RepresentationAnother method used to represent negative numbers (used by most modern computers) is two’s complement. The leftmost bit STILL serves as a sign bit: 0 for positive numbers, 1 for negative numbers.Two’s Complement RepresentationTo compute negative values using Two’s Complement representation:1) Begin with the binary representation of the positive value2) Complement (flip each bit -- if it is 0 make it 1 and visa versa) the entire positive number3) Then add one.Two’s Complement RepresentationEx 1. Find the 8-bit two’s complement representation of –610Step 1: Find binary representation of the positive value in 8 bits 610 = 000001102Two’s Complement Representation Ex 1 continuedStep 2: Complement the entire positive valuePositive Value: 00000110 Complemented: 11111001Two’s Complement RepresentationSo: -610 = 111110102 (in 8-bit 2's complement form) Ex 1, Step 3: Add one to complemented value (complemented) -> 11111001(add one) -> + 1 11111010Two’s Complement RepresentationEx 2. Find the 8-bit two’s complement representation of 2010Step 1: Find binary representation of the positive value in 8 bits 2010 = 00010100220 is positive, so STOP after step 1!So: 2010 = 000101002 (in 8-bit 2's complement form)Two’s Complement RepresentationEx 3. Find the 8-bit two’s complement representation of –8010Step 1: Find binary representation of the positive value in 8 bits 8010 = 010100002-80 is negative, so continue…Two’s Complement Representation Ex 3 Step 2: Complement the entire positive valuePositive Value: 01010000 Complemented: 10101111Two’s Complement RepresentationSo: -8010 = 101100002 (in 8-bit 2's complement form) Ex 3, Step 3: Add one to complemented value (complemented) -> 10101111(add one) -> + 1 10110000Try It YourselfConvert the following decimal numbers to 8-bit 2’s complement representation:-7345-97(Answers on NEXT slide)Answers-73 = 1011011145 = 00101101-97 = 10011111Two’s Complement Representation Alternate method -- replaces previous steps 2-3 Step 2: Scanning the positive binary representation from right to left, find first one bit, from low-order (right) endStep 3: Complement (flip) the remaining bits to the left. 00000110 (left complemented) --> 11111010Two’s Complement RepresentationEx 1: Find the Two’s Complement of -7610 Step 1: Find the 8-bit binary representation of the positive value. 7610 = 010011002Two’s Complement RepresentationStep 2: Find first one bit, from low-order (right) end, and complement the pattern to the left. 01001100 (left complemented) -> 10110100 So: -7610 = 101101002 (in 8-bit 2's complement form)Two’s Complement RepresentationEx 2: Find the Two’s Complement of 7210 Step 1: Find the 8 bit binary representation of the positive value. 7210 = 010010002Steps 2-3: 72 is positive, so STOP after step 1! So: 7210 = 010010002 (in 8-bit 2's complement form)Two’s Complement RepresentationEx 3: Find the Two’s Complement of -2610 Step 1: Find the 8-bit binary representation of the positive value. 2610 = 000110102Two’s Complement RepresentationEx 3, Step 2: Find first one bit, from low-order (right) end, and complement the pattern to the left.


View Full Document

RU CS 208 - Signed Numbers

Download Signed Numbers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Signed Numbers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Signed Numbers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?