Download presentation
Presentation is loading. Please wait.
1
COMS 161 Introduction to Computing
Title: Numeric Processing Date: October 27, 2004 Lecture Number: 25
2
Announcements Homework 7 Due Wednesday, 11/03/2004
3
Review Integers Numeric Processing Magnitude representation
Sign-magnitude representation
4
Outline Integers Numeric Processing Real numbers
Ones’s complement representation Two’s complement representation Real numbers
5
Sign-Magnitude Mathematical operations sometimes give an incorrect result 4 – 3 = = 1 +(-3) 1 1 1 1 1 -7
6
Ones compliment Positive integers have the most significant bit (leftmost) equal to 0 The magnitude of positive numbers is the same as the signed magnitude representation Negative integers have the most significant bit equal to 1 The magnitude of a negative number is the same as the magnitude representation of a different number
7
Ones compliment Unsigned decimal Ones complement Signed decimal 000 1
000 1 001 2 010 3 011 4 100 -3 5 101 -2 6 110 -1 7 111 -0 -3 = 23 – 1 – 3 = 8 – 4 = 4 -2 = 23 – 1 – 2 = 8 – 3 = 5 -1 = 23 – 1 – 1 = 8 – 2 = 6 -0 = 23 – 1 – 0 = 8 – 1 = 7
8
Ones compliment Example: let n = 8, and N = 5
There is something special here and in the previous table Negatives are made from the positive by inverting each bit! Simpler hardware for arithmetic operations Still two representations of zero
9
Ones complement
10
Ones complement Mathematical operations sometimes give an incorrect result using this representation Two representations of zero 4 – 3 = = 1 4 – 2 = = 2 +(-3) +(-2) 1 1 2 1
11
Twos Complement Positive integers have the most significant bit (leftmost) equal to 0 The magnitude of positive numbers is the same as signed magnitude and ones complement representations Negative integers have the most significant bit (leftmost) equal to 1 Negative numbers can be computed as:
12
Two’s Complement Example: let n = 8, and N = 5
There is something special here ones’ complement two’s complement It is simple to determine the representation of a negative number in ones complement given the positive It is easy to convert a ones complement representation to a twos complement representation by simply adding 1
13
Twos Complement
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.