Negative Numbers - Brown University
[Pages:29]Negative Numbers
CS31 Pascal Van Hentenryck
CS031
Lecture 2
1
Overview
Negative Numbers
? Signed Numbers ? Addition and Subtraction ? Properties ? Overflows
CS031
Lecture 2
2
The Big Picture
compiler computer
control input
datapath
processor
CS031
memory
Lecture 2
output
3
Abstraction Hierarchy
Programming Language
Assembly Language Machine Language Sequential Circuit Combinational Circuit
Binary Value Voltage
CS031
Lecture 2
4
Signed Numbers
Two issues in representing negative numbers
? How to represent the sign? ? How to represent the value?
Goal of representation
? Simplifying hardware as much as possible
? Addition, subtraction should be simple
Desirable Properties
? Unique representation of zero ? As many positive and negative
numbers
CS031
Lecture 2
5
Signed Numbers
Three main schemes
? Signed magnitude ? 1's compliment ? 2's compliment
Commonalities
? How they represent the sign ? How they represent positive
values
Main difference
? How to represent negative values
CS031
Lecture 2
6
Signed Magnitude
This is what we do all the time
+36
-497
? sign bit: most significant bit (MSB)
? the remaining bits give the magnitude in unsigned representation
Example +3610 = 001001002 - 3610 = 101001002
10000000000000000000000000100100
? What's the largest positive value representable in n bits? (2n-1) ? 1
? What's the smallest (most negative) value? -(2n-1) + 1
? How is 0 represented? 00000000 OR 10000000
CS031
Lecture 2
7
Addition and Subtraction
To add signed numbers
? If they have the same sign, perform unsigned addition on the magnitudes and preserve the sign
? If they have different signs, subtract the smaller magnitude from the larger and take the sign of the larger
To subtract
? Change the sign of the subtrahend and add
Issues
? Many special cases ? Hairy to design the circuit ? Multiple representations of zero
CS031
Lecture 2
8
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- lesson 10 overview add and subtract positive and negative
- lesson 3 introduction add and subtract positive and
- working with integers 1 adding rules
- negative numbers brown university
- add subtract negative numbers sheet 3
- adding and subtracting positive and negative fractions
- add subtract negative numbers sheet 1
- binary arithmetic negative numbers and subtraction
- rules for adding subtracting multiplying and dividing
- ceenbot tekbot site ece scott campus omaha
Related searches
- adding positive and negative numbers worksheet
- adding and subtracting negative numbers worksheets
- subtracting negative numbers calculator
- adding and subtracting negative numbers calculator
- math negative numbers practice
- positive and negative numbers worksheets
- adding and subtracting negative numbers pdf
- why are negative numbers important
- negative numbers worksheets
- adding negative numbers khan academy
- positive and negative numbers khan
- negative numbers to binary