Академический Документы
Профессиональный Документы
Культура Документы
Negation
x + x = 1111…1111two = -1 (in 2’s complement)
Therefore, -x = x + 1
Sign Extension
o Positive numbers : easy
o Negative numbers (2’s complement):
- 4 in 4 bits : 1100
- 4 in 5 bits : 11100
Why is this useful?
1. Actual sign extension
2. Binary to decimal conversion (2’s complement)
-- can forget about leading 1’s
e.g. 1111 1110two = 110two = -2ten
Negative Binary to Decimal
Changing sign
What pattern appears at the right end ?
1 followed by some (or no) 0’s
What is multiplication by 2 ?
5 x 2 = 10ten
101two x 2 = ?
(can you use this in efficiently solving 4.11?)
e.g. 01110000100101two
= 0001 1100 0010 0101two
= 1c25hex
“Bits have no inherent meaning”
unsigned : 14
signed : ??? (can assume 2’s complement)
2’s complement : - (0010two) = -2
1’s complement : - (0001two) = -1
sign and magnitude : - (110two) = -6
Overflow and Underflow