Special Powers of 2
Special Powers of 2
Binary 1 1 1 0 0 1 0 1
1’s complement 0 0 0 1 1 0 1 0
Finding the 2’s Complement
Add 1 to the 1’s complement to get the
2’s complement.1’s complement
+1
2’s complement
00011001
While the decimal number -25 is expressed as
10011001
Sign-Magnitude Form
00011001
While the decimal number -25 is expressed as
11100111
2’s Complement Form
1) 10010101 2) 01110111
magnitude magnitude
26 25 24 23 22 21 20 26 25 24 23 22 21 20
0 0 1 0 1 0 1 1 1 1 0 1 1 1
1) 00010111 2) 11101000
-27 26 25 24 23 22 21 20 -27 26 25 24 23 22 21 20
0 0 0 1 0 1 1 1 1 1 1 0 1 0 0 0
1) 01010110 2) 10101010
-27 26 25 24 23 22 21 20 -27 26 25 24 23 22 21 20
0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0
Negative Positive
Boundary Boundary
4 bits -(23) = -8 (23-1) = +7
8 bits -(27) = -128 (27-1) = +127
16 bits -(215) = (215-1) =
-32,768 +32767
Arithmetic Operations with
Signed Numbers
Because the 2’s complement form
for representing signed numbers is
the most widely used in computer
systems. We’ll limit to 2’s
complement arithmetic on:
– Addition
– Subtraction
– Multiplication
– Division
Addition
4 cases that can occur when 2
signed numbers are added:
– Both numbers positive
– Positive number with magnitude larger
than negative number
– Negative number with magnitude
larger than positive number
– Both numbers negative
Addition
Both numbers positive:
ex: 00000111 7
+00000100 +4
00001011 11
ex: 00001111 15
+11111010 + -6
Discard 1 00001001 9
carry
ex: 00010000 16
+11101000 + -24
11111000 -8
ex: 11111011 -5
+11110111 + -9
Discard 1 11110010 -14
carry
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!
http://ascii-table.com/img/table.gif
Extended ASCII
There are an additional 128
characters that were adopted by
IBM for use in their PCs. It’s
popular and is used in applications
other than PCs unofficial
standard.
– The extended ASCII characters are
represented by an 8-bit code series
from 80h-FFh
Extended ASCII
Table
http://ascii-table.com/img/table-pc.gif
UNICODE
UNICODE extends ASCII to 65,536
universal characters codes
– For encoding characters in world
languages
– Available in many modern applications
– 2 byte (16-bit) code words
– See Reading Supplement – Unicode on
the Companion Website
http://www.prenhall.com/mano
Read and try to Understand the
Greys code from your Text book.
We shall have a discussion on it in
the next class