lecture16 - magnitude of the result is >= 2 n-1 b b For...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPT 150 Integer Representation Page 1 Integer Representation in Binary We have three possible signed representations: b Signed-magnitude representation b Easiest for humans to understand, but cumbersome to use directly in the computer (e.g. subtraction) b Signed 1’s complement representation b Need to add the 1 after the subtraction b Two representations for zero (e.g. for n=4, 0000 and 1111) b Signed 2’s complement representation b Easiest subtraction and only one representation for zero b This is the representation that is used in computers! CMPT 150 Integer Representation Page 2 Integer Representation in Binary E.g. b b Note: unsigned integers are used for addresses CMPT 150 Integer Representation Page 3 Overflow b For n digits of precision, we get overflow when the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: magnitude of the result is >= 2 n-1 b b For unsigned numbers: b Overflow occurs when there is an end-carry b For signed numbers: b Overflow occurs when there is a sign-reversal b We can detect the overflow when the carry-in does not equal the carry-out in the sign-bit CMPT 150 Integer Representation Page 4 Overflow b For example: b We can use an XOR gate to detect overflow CMPT 150 Integer Representation Page 5 2s Complement Addition b Add the numbers together and discard the carry b E.g. for n=6 : CMPT 150 Integer Representation Page 6 2s Complement Subtraction b Take 2s complement of second operand and perform 2s complement addition b n=5 , perform 10 10 3 10 b Now perform 3 10 10 10...
View Full Document

This note was uploaded on 04/27/2011 for the course CMPT 150 taught by Professor Dr.anthonydixon during the Spring '08 term at Simon Fraser.

Page1 / 2

lecture16 - magnitude of the result is >= 2 n-1 b b For...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online