Two's complement: Am I on the right track here?

  • Thread starter Horizyn
  • Start date
  • Tags
    Track
In summary, two's complement is a mathematical operation used in computer programming to represent negative numbers in binary form. It is preferred over other methods because it is easy to implement and simplifies arithmetic operations on signed integers. Two's complement can be used for both positive and negative numbers, but it has a limitation of only representing a fixed range of numbers which can lead to overflow or underflow issues if the number is too large.
  • #1
Horizyn
2
0
What is the the 2's complement representation of -14 using 5 bits?

1. (11110)2
2. (10100)2
3. (11001)2
4. (10010)2

I've changed to binary: 01110
Flipped over as in two's complement: 10010

So the likely answer seems to be option 4

Am I missing something?

Thanks
 
Physics news on Phys.org
  • #2
To take the negative of a number in two's complement, you can take the one's complement (invert all the bits), then increment by 1. In this case ~01110 = 10001, then increment by 1 = 10010. Negating again, ~10010 = 01101, then increment by 1 = 01110.
 
  • #3
As a check, if you add the binary representation of 14 to its two's complement representation, you should get 5 bits of 0.
 

1. What is two's complement?

Two's complement is a mathematical operation used to represent negative numbers in binary form. It involves flipping all the bits and adding 1 to the result.

2. How is two's complement used in computer programming?

In computer programming, two's complement is used to perform arithmetic operations on signed integers. It allows for a more efficient way of representing and manipulating negative numbers.

3. Why is two's complement used instead of other methods for representing negative numbers?

Two's complement is preferred over other methods because it is easy to implement in hardware and it simplifies the process of subtraction, making it more efficient.

4. Can two's complement be used for both positive and negative numbers?

Yes, two's complement can be used to represent both positive and negative numbers. It is the most common method for representing signed integers in computer systems.

5. Are there any limitations to using two's complement?

One limitation of two's complement is that it can only represent a fixed range of numbers. The size of the binary number determines the range, and if the number is too large, it can lead to overflow or underflow issues.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
809
  • Engineering and Comp Sci Homework Help
Replies
6
Views
9K
  • Introductory Physics Homework Help
Replies
16
Views
654
Back
Top