Twos Complement numbers - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Twos Complement numbers

Description:

A positional number system that allows the representation of positive and ... ( it does not mean a carry 'overflowed') Two negative yield a positive! 11/4/09. 5 ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 7
Provided by: jorgecr
Category:

less

Transcript and Presenter's Notes

Title: Twos Complement numbers


1
Twos Complement numbers
Lecture Notes Lab 4
A positional number system that allows the
representation of positive and negative numbers
Sign Magnitude 000 0001 1 010 2 011
3 100 -0 101 -1 110 -2 111 -3
Ones Complement 000 0001 1 010 2 011
3 100 -3 101 -2 110 -1 111 -0
Twos Complement 000 0001 1 010 2 011
3 100 -4 101 -3 110 -2 111 -1
2
Creating a Two's Complement of a Negative Number
Lecture Notes Lab 4
1. Represent the magnitude of the number in
binary
3 011
2. Invert all bits (ones complement)
011 -gt 100
3. Increment the binary number by one
101 -3
3
Maximum and Minimum Values
Lecture Notes Lab 4
Example 3-bits system
000 0001 1 010 2 011 3
100 -4 101 -3 110 -2 111 -1


2 bits -gt 22 positive numbers 0 to 3(22 -1)
2 bits -gt 22 negative numbers -1 to -4
MAX 2n-1 - 1 MIN -2n-1
4
Twos complement operations
Lecture Notes Lab 4
Addition
001 1 010 2
101 -3 010 2
101 -3 110 -2
011 3 010 2




011 3
111 -1
1011 of
101 of
Two negative yield a positive!
Two positive yield a negative! (it does not mean
a carry overflowed)
5
Twos complement operations
Lecture Notes Lab 4
Subtraction
010 2 001 1
001 1 010 2
001 1 110 -2
010 2 111 -1

-

-
011 3
111 -1
110 -2 011 3
110 -2 101 -3
010 2 101 -3
010 2 011 3
-

-

1011 of
101 of
Subtract a positive from a negative yields
positive!
Subtract a negative from a positive yields a
negative!
6
Design of an Adder/Substractor
Lecture Notes Lab 4
By using structural behavior, the system consists
on the specification of the connection among the
different subsystems
See example in black_box.vhd
Write a Comment
User Comments (0)
About PowerShow.com