CSE 120 Lecture Notes - Lecture 8: Signed Number Representations, Binary Number
CSE 120 Lecture Eight Notes - 2’s Complement Representation, 2’s Complement
Arithmetic
2’s Complement Representation
● Mathematical operation on binary numbers
● Computing as a method of signed number representation
● 2’s complement of an N-bit number is defined as its complement with respect to 2𝑁
○ Example:
■ Three bit number 010
■ Two’s complement is 110 because 010 + 110 = 1000
● Most common method of representing integers
● Arithmetic in 2’s complement is the same as unsigned binary numbers
○ Simpler to implement
● Way to take another complement
○ Take its one’s complement and add one
○ 2𝑁 − 1
● Special Numbers to note
Decimal
2’s Complement
127
0111 1111
64
0100 0000
1
0000 0001
0
0000 0000
-1
1111 1111
-64
1100 0000
-127
1000 0001
-128
1000 0000
2’s Complement Arithmetic