{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture16

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

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

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

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

View Full Document
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 2’s Complement Addition b Add the numbers together and discard the carry b E.g. for n=6 : CMPT 150 Integer Representation Page 6 2’s Complement Subtraction b Take 2’s complement of second operand and perform 2’s complement addition b n=5 , perform 10 10 – 3 10 b Now perform 3 10 – 10 10...
View Full Document

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online