Number Representation
How do we represent signed (positive & negative) numbers?
Option 3: Two's Complement ☜ ✓ ★ ☺
- Flip every bit to represent the number's negative value, then
add one
(Note: surprisingly, this also works both ways!)
- Left-most bit still represents the sign
- Examples:
00000001
= +1
11111111
= -1 (two's complement)
00000101
= +5
11111011
= -5 (two's complement)
01111111
= +127
10000001
= -127 (two's complement)
- Problem 1 Solved!
00000000
= +0
00000000
= -0 (two's complement)
- Problem 2 Solved!
00000101
5
11111111
+ -1
--------
-----
100000100
4 (ignore overflow)
Alyce Brady, Kalamazoo College