













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














We now address the issue of representing integers as binary strings in a computer. There are four formats that have been used in the past; only one is of interest to us. The four formats are
In each of one’s–complement and two’s–complement arithmetic, no special steps are required to represent a non–negative integer. All conversions to the complement number systems begin with conversion to simple binary representation, often from decimal notation. The only issue with non–negative integers is to insure that the number is not too large for the number of bits used in the representation. There are two ways to define this size limitation in the complement numbers system.
To take the one’s complement of a binary integer, just Change every 0 to a 1 Change every 1 to a 0 One’s–complement arithmetic is that arithmetic that uses the one’s–complement of a binary integer to represent its negative. + 100 in 8–bit one’s complement. 0110 0100.
- 100 in 8–bit one’s complement. Convert 100 to 8–bit binary 0110 0100 Take the one’s complement 1001 1011 - 100 is represented as 1001 1011 + 22 is 8–bit one’s complement 0001 0110 - 22 in 8–bit one’s complement Convert 22 to 8–bit binary 0001 0110 Take the one’s complement 1110 1001 - 22 is represented as 1110 1001 We no longer use one’s–complement arithmetic. It has two serious problems.
There are two serious problems with the use of one’s–complement arithmetic. The first one will be described but not explained. Problem 1: It is a lot trickier to build a binary adder for one’s–complement numbers. Just take my word for this one. Problem 2: Negative Zero Consider 8–bit one’s–complement arithmetic
Consider 5 + 7 5 = 0101 7 = 0111 1100 12
The recipe for taking the two’s–complement of a binary number is simple.
Remember that the range of 8–bit two’s–complement arithmetic is – 128 to 127. + 100 in 8–bit two’s–complement binary 0110 0100
Remember that the range of 8–bit two’s–complement arithmetic is – 128 to 127. + 22 in 8–bit two’s–complement binary 0001 0110
N–
N–
63
63
63
2
63
18
N–
N–
N–
There is a difference between the idea of a complement system and the process of taking the complement. Two’s–complement arithmetic is a system of representing integers in which the two’s- complement is used to compute the negative of an integer. For positive integers, the method of conversion to binary differs from unsigned integers only in the requirement to use a fixed number of bits; this may give leading zeroes. Question: What is the representation of the positive number 123 in 8–bit two’s complement arithmetic? Answer: 0111 1011. Note that I did not take the two’s complement of anything to get this. Question: What is the representation of the negative number –123 in 8–bit two’s complement arithmetic? Answer: I take the two’s complement of 0111 1011 to get 1000 0101. Summary: Speaking of the two’s-complement does not mean that one must take the two’s-complement of anything.