answersLogoWhite

0

Let's consider any number, for example a byte of data represented as eight bits. The values that this byte can have are 00000000 through 11111111. The easiest way to find the one's complement is to change the zeros to one and the ones to zeros.

The limits shown above can be represented as 00 through FF in hexadecimal. Let's consider a number AF which is within this boundary. The easiest way to find the one's complement when numbers are represented in hexadecimal form is to subtract the number from (in this case) FF. You will have more F's depending on the length of the number you want to find the one's complement for. If the number consists of three hex digits then you subtract from FFF, if four then from FFFF and so on. Thus with our example of AF, its one's complement would be

FF

AF

---

50

---

If you add 1 to this result you will get the two's complement of the number AF.

Hence the two's complement of AF is (50 + 1) = 51 in hex. Observe that the process of finding one's complement or two's complement of a number are reversible and the original number is obtained. Thus the one's complement of the one's complement of a number gives the original number. The two's complement of the two's complement of a number gives the original number. Lets consider the hex number FF. Its one's complement is 00 and the two's complement is 01.

So far we have talked about two's complement of a number (and in the process the one's complement as well).

It is not possible to explain two's complement representation without understanding hardware implementation on a computing device, namely, a computer. Let's consider a byte machine where you can operate only on single bytes. Thus you can add two bytes, subtract a byte from another and so on.

If two's complement representation of numbers is not implemented on a machine, then the byte can hold values hex 00 through hex FF which would be 0 through 255 in decimal. If 1 is added to a byte containing FF on this machine, the contents of the byte will change to 0 and the overflow bit in the computer will be set to TRUE.

If however, two's complement representation of numbers is implemented on a machine the MSB (most significant bit) in the byte is the sign bit. If it is set then the number is negative and if it is not set then the number is positive. Since one bit of the 8 bits in our byte machine is taken up to represent the sign, only the remaining 7 bits can hold the magnitude of the number. The range of positive number in such a machine is hex 00 through hex 7F which is 0 through 127.

If you add 1 to 7F then the contents of the byte would be hex 80.

Notice that this is a negative number because the MSB is set. But how negative is this number. Since the machine implements two's complement representation of number on this machine, subtract (hex 80) from hex FF and add 1 to get hex 80 which equals 128. So the byte machine which implements two's complement can represent values from -128 through +127. In general if a machine implements 16, 32, or 64 bit architecture, the numbers that they can hold if they implement two's complement are between -(2*n) through and including +(2*n - 1) where n is 16, 32, or 64.

I hope you have a better understanding of the difference between two's complement of a number and its representation (meaning implementation) on a computer.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

What is the difference between a diploid and a heploid cell?

A diploid cell has a full complement of chromosomes. A haploid cell has half the number of chromosomes as a diploid cell.


What is the 8-bit sign-and-magnitude representation of the decimal number -2?

10


How do you calculate 2s complement of any binary number?

To calculate the 2's complement of a binary number, first, invert all the bits (change 0s to 1s and 1s to 0s), which is known as finding the 1's complement. Then, add 1 to the least significant bit (LSB) of the inverted binary number. The result is the 2's complement, which represents the negative of the original binary number in signed binary representation.


Twos complement of a given 3 or more bit binary number of non-zero magnitude is the same the original number if all bits except the?

ANSWER: MSB IS 1 In the 2's complement representation, the 2's complement of a binary number is obtained by first finding the one's complement (flipping all the bits), and then adding 1 to the result. This representation is commonly used to represent signed integers in binary form. Now, if all bits except the sign bit are the same, taking the 2's complement of the binary number will result in the negative of the original number. The sign bit (the leftmost bit) is flipped, changing the sign of the entire number. For example, let's take the 4-bit binary number 1101 The 2's complement would be obtained as follows: Find the one's complement: 0010 Add 1 to the one's complement: 0011


What is the difference between 0 73 and 38.5?

The first number is 0, the additive identity for the set of numbers. The second, 73 is a positive integer or counting number and the third, 38.5 is a decimal representation of a rational number.


What is the difference between the greatest number and the least number?

The difference between the greatest and least number is the range.


Working of difference engine?

Mechanical implementation of the solution of a difference equation (discrete version of differential equation). It does repeated additions of one value to the next value. With proper analysis and programing it can solve any polynomial equation that fits on the machine. Using a 10s complement signed number representation addition could also simulate subtraction.


Why 2's complement binary subtraction is preffered over 1's complement binary subtraction?

1


What is good about the two's complement representation?

Two's complement representation simplifies binary arithmetic, particularly for subtraction, by allowing both positive and negative numbers to be processed uniformly within the same binary system. It eliminates the need for separate negative number handling, as the most significant bit indicates the sign of the number. Additionally, it allows for an easy detection of overflow and simplifies the design of arithmetic circuits in digital systems. Overall, two's complement is efficient and widely used in computing for representing signed integers.


The difference between a number and 3?

the difference between a number and 3 is


The difference between one number and the next on the scale?

the difference between ine number and the next on the scale ?


What is the difference between Mnemonics and hexadecimal representation?

Mnemonics is a method of remembering things by associascation. Hexadecimal is a number system. 0-9 are as usual and then a(10) b(11) c(12) d(13) e(14) f(15)