SLIDE 1
1
CSCI 125 & 161 / ENGR 144 Lecture 5
Martin van Bommel
16-bit Memory Word
- To store number 6, use 0000000000000110
- Value 0 is 0000000000000000
- Largest value is
1111111111111111 = 65,535 = 216 − 1
- 32-bit word gives largest value > 4 billion
Storing Negative Values
- Sign Magnitude
– use first bit as sign bit, 0 = positive 1 = negative – e.g. 8-bits 00000000 = 0 10000000 = −0 00000001 = 1 10000001 = −1 … … 01111111 = 127 11111111 = −127
Two’s Complement
- Two’s complement
– if positive, use binary – if negative, complement bits and add one – e.g. −53 magnitude 00110101 complement 11001010 add 1 11001011
8-bit Two’s Complement
00000000 = 0 00000001 = 1 11111111 = −1 00000010 = 2 11111110 = −2 … … 01111111 = 127 10000001 = −127 10000000 = −128
Two’s Complement Addition
- Add −1 + 2?
−1 11111111 +2 00000010
- +1