Binary adding/subtracting, am i doing this right?

  • Thread starter mr_coffee
  • Start date
  • Tags
    Binary
In summary, The speaker is trying to understand how to perform subtraction with unsigned binary numbers using the 2's compliment method. They explain their process of taking the 2's compliment of the subtrahend and adding it to the minuend. They also question the final answer and provide an example with a larger number.
  • #1
mr_coffee
1,629
1
Hello everyone, I'm alittle confused, we have an exam tomarrow and i want to make sure I'm doing this right. I'm suppose to do the following:
Perform the indicated subtraction with the following unsigned binary numbers by taking the 2's compliment of the subtrahend.
so for one of them:
10110 - 1111
I take the 2's compliment of 1111 which is:
1's compliment: 0000
2's compliment: 0000 + 1 = 0001
now i add 0001 to 10110
10110
+0001
=
10111

now since I'm only adding a 4 bit number to a 5 bit number my final answer will only still be in 4 bits right? so it would be
0111 as the final answer right?
I used a binary calculator and it said the answer is 111, but i think it just wasn't programmed to included the 0 infront.
 
Physics news on Phys.org
  • #2
Also what would
101 - 101000 equal? the calculaotr came out with a huge number:
1111111111111111111111111111111111111111111111111111111111011101when i take the 2's compliment of 101000 and add it to 101 i get: 011101
 
  • #3


Hello, it appears that you are on the right track with your approach to binary adding and subtracting. Taking the 2's compliment of the subtrahend is a common method for performing subtraction in binary. However, I would like to clarify a few things for you.

First, when taking the 2's compliment, you should be flipping all the bits (changing 0s to 1s and 1s to 0s) of the subtrahend and then adding 1. In your example, the 1's compliment of 1111 would be 0000, but the 2's compliment would be 0001, not 0000 + 1.

Second, when adding the 2's compliment to the minuend (the first number being subtracted), you should be adding all the bits, including the leading 0s. So in your example, it would be 0001 + 10110, which equals 10111.

Lastly, the final answer should always be in the same number of bits as the minuend. In this case, since the minuend has 5 bits, the final answer should also have 5 bits. So the correct answer for 10110 - 1111 would be 01011 in binary.

I would recommend practicing a few more examples and double checking your steps to ensure you have a solid understanding of binary adding and subtracting. Best of luck on your exam tomorrow!
 

1. What is binary adding/subtracting?

Binary adding and subtracting is a method of performing mathematical operations with binary numbers, which are numbers expressed in a base-2 system using only two digits: 0 and 1. It is the fundamental building block of computer programming and digital technology.

2. How do I add or subtract binary numbers?

To add or subtract binary numbers, you can use the same methods as you would with decimal numbers, but with only two digits to work with. Start by aligning the numbers vertically, with the ones digit on the right. Then, add or subtract each column from right to left, carrying or borrowing as needed. For example, to add 1 + 1 in binary, the sum would be 0 with a carry of 1 to the next column.

3. What are some common mistakes to avoid when doing binary addition/subtraction?

Some common mistakes to avoid when working with binary numbers include forgetting to carry or borrow when necessary, mixing up the order of digits in a number, and incorrectly converting between binary and decimal numbers. It is important to double check your work and practice regularly to become comfortable with the process.

4. How can I check if I am doing binary addition/subtraction correctly?

To check if you are doing binary addition/subtraction correctly, you can convert the binary numbers to decimal and perform the same operation. If the answer matches, then you have likely done it correctly. Additionally, there are online tools and calculators available that can help you verify your work.

5. Are there any tips for becoming proficient in binary addition/subtraction?

Practice and repetition are key to becoming proficient in binary addition/subtraction. It is also helpful to understand the underlying concepts, such as place value and carrying/borrowing, and to familiarize yourself with common patterns and shortcuts. Additionally, seeking out resources such as tutorials, practice problems, and online tools can also aid in improving your skills.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
12K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top