Two's Complement Representation

In summary, two's complement representation is a method of representing signed integers in binary form, where the leftmost bit represents the sign. To calculate it, the binary representation of the positive number is flipped and 1 is added to the result. This method allows for efficient mathematical operations and has a range of -2^(n-1) to 2^(n-1) - 1 with n bits. It is commonly used in computer systems due to its efficiency and ability to represent a wide range of numbers. Other advantages include its simplicity and widespread usage.
  • #1
sandy.bridge
798
1

Homework Statement


When determining the two's complement of a decimal number, one converts the decimal to binary, finds the complement of each individual digit, adds one, and there we have it.

For example,
-4=1100--->0011+1=0100=+4

However, when I apply the same logic for -99, I don't seem to get the same type of results
-99=11100011--->00011100+1=00011101=29
does anyone see where I am going wrong here?
 
Physics news on Phys.org
  • #2
Figured it out!
 

Related to Two's Complement Representation

1. What is two's complement representation?

Two's complement representation is a method of representing signed integers in binary form. It is based on the idea that the leftmost bit of a binary number represents the sign, with 0 indicating a positive number and 1 indicating a negative number. This method allows for efficient mathematical operations on signed integers in computer systems.

2. How is two's complement representation calculated?

To calculate the two's complement representation of a number, the following steps can be followed:

  1. Write the binary representation of the positive number.
  2. Flip all the bits (change 0s to 1s and 1s to 0s).
  3. Add 1 to the result.

The final result is the two's complement representation of the original number.

3. What is the range of numbers that can be represented using two's complement representation?

With n bits, two's complement representation can represent numbers in the range of -2n-1 to 2n-1 - 1. For example, with 8 bits, the range is -128 to 127.

4. Why is two's complement representation used in computer systems?

Two's complement representation is used in computer systems because it allows for efficient mathematical operations on signed integers. It also simplifies the logic needed for addition and subtraction, making it a more practical choice for computers.

5. What are the advantages of using two's complement representation?

The advantages of using two's complement representation include its ability to represent both positive and negative numbers using the same binary system, simplifying mathematical operations, and the ability to represent a wider range of numbers compared to other signed integer representations. Additionally, two's complement is the most commonly used method for representing signed integers in computer systems, making it a standardized and widely understood system.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
Replies
17
Views
1K
Back
Top