CSE 220 Lecture Notes - Lecture 3: Sign Bit, Negative Number, Arithmetic Shift

37 views6 pages

Document Summary

There are several different signed integer encodings which permit the representation of both positive and negative numbers. The hardware designer chooses between the encodings to make the arithmetic hardware simpler or more efficient for certain operations. Sometimes the programmer needs to be aware of what encoding is being used. To understand the range of representable values and the conditions under which overflow can occur. In n-bit sign/magnitude encoding, the msb (leftmost) is used as a sign bit, and the remaining n-1 (7 for 8 bit numbers) represent the magnitude of the number, as in the unsigned scheme. The n-bit one"s complement encoding represents integers in the range [-(2^n-1 - 1), 2^n-1 - 1] To negate a number, simply flip all the bits. Flipping a bit is called taking the one"s complement. If these were unsigned numbers, there would be overflow since the 1 in the msb (leftmost) will be thrown away giving the wrong answer.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents