This preview shows pages 1–3. Sign up to view the full content.
1
ECE 15A
Fundamentals of Logic Design
Lecture 2
Malgorzata MarekSadowska
Electrical and Computer Engineering Department
UCSB
Representing negative numbers
A negative number is usually indicated by its complement.
2’s complement
is the most common.
Example:
2
+11
:
00001011
11
:
10001011
(signed magnitude)
11110100
(signed one’s complement)
11110101
(signed two’s complement)
Signed 2’s complement has only one representation for 0 (+)
One's complement format  8 bit arithmetic
Change the number N to binary, ignoring the sign.
Add 0s to the left of the binary number to make a
total of 8 bits
3
If the sign is positive, do nothing.
If the sign is negative, complement every bit (i.e.
change from 0 to 1 or from 1 to 0)
In this way we compute (2
1)  N
8
One's Complement
to Decimal
Convert the following 1's complement
representation to decimal:
a)
11110001
Since the sign bit is 1, complement the number:
4
00001110
Convert to decimal:
00001110
2
= 14
10
Put a negative sign in front:
14
b)
00011010
>
26
Example
Write 25 in one's complement
0 0 0 1 1 0 0 1
25
5
Write 25 in one's complement
Since the number is negative, complement each bit
1 1 1 0 0 1 1 0
25
Two's complement format  8 bit arithmetic
Most computers today use 2's complement
representation for negative numbers.
The 2's complement of a negative number N is
obtained by adding 1 to the 1's complement.
6
This is the same as computing 2  N
For 13
00001101
base integer
11110010
1's complement
+1
11110011
2's complement
8
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document 2
Example
Write 25 in two's complement format.
0 0 0 1 1 0 0 1
25
11100110
ne
'sc mplemen
7
1 1 1 0 0 1 1 0
one's complement
1 1 1 0 0 1 1 1
two's complement
Two's Complement to Decimal
If the sign bit is 0, convert the binary number
to decimal.
If the sign bit of N is 1
8
Compute 2’s complement of N
convert the binary number to decimal
put a minus sign in front
Example
Convert the following 2's complement
representation to decimal:
11100011
Compute 2’s complement:
9
11100011 > (1’s complement: 00011100) >
(Add 1: 00011101)
(change to decimal) > 29 > (put – in front)
> 29
Complements
Used to simplify the subtraction
Arithmetic subtraction
10
(+A)  (+B) = (+A) + (B)
(+A)  (B)
=(+A) + (+B)
Example (1s complement)
Application:
11000000
<=>
1
1 0
0
0
0 0 0
00100111
+
1
1
0
1
1
0
0
0
1
100110 00
(
one’s complement)
11
+
1
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 02/26/2011 for the course ECE 15A taught by Professor M during the Winter '08 term at UCSB.
 Winter '08
 M

Click to edit the document details