Executing Arithmetic Operations w/ 6-Bit Binary Numbers

In summary, for executing arithmetic operations using 6-bit binary numbers in 2's complement representation, it is important to understand how to convert from regular binary numbers to 2's complement and how to add two numbers in 2's complement form. It is also important to understand how to detect overflow and when to complement the answers to check for accuracy. It is recommended to practice using both the regular binary values and 2's complement values for positive and negative numbers to ensure a solid understanding.
  • #1
DrOnline
73
0

Homework Statement


Execute the arithmetic operations using 6-bit binary numbers in 2's complement representation.

18+11

(just going to list this first task)

Homework Equations


To convert from regular binary number, from LSB, do not invert initial o's, or first 1, but invert all other values.

+18 = 010010
-18 = 101110

+11 = 001011
-11 = 110101

I understand the thinking of the MSB being, for -18 2's comp: -32, then adding 8, 4 and 2 = -18

The Attempt at a Solution



But I don't know when to use complements.

A)18+11. I get the right answer using two methods:

If I simply add their regular binary values I get 29.

But I also get it right if I add both of their 2's complements, and then complement the answer.

101110
+ 110101
=[STRIKE]1[/STRIKE]100011
answer complements into: 011101 = 29

But now I had overflow, and it still gets it right.

Which of these methods are correct, in accordance with logic, and even more important, in accordance with what was asked in the task?

Seems to me, that using complements in this simply addition of positive numbers, first of all gave me overflow, but also required an additional complementing?

B: When do I have to complement the answers? Is there a logic so I know when to do it?
 
Physics news on Phys.org
  • #2
DrOnline said:
To convert from regular binary number, from LSB, do not invert initial o's, or first 1, but invert all other values.
The normal and somewhat easier rule to complement a number is to invert all the bits (ones complement), then increment the result by 1.

+18 = 010010
-18 = 101101 + 1 = 101110

-18 = 101110
+18 = 010001 + 1 = 010010

+11 = 001011
-11 = 110100 + 1 = 110101

-11 = 110101
+11 = 001010 + 1 = 001011

DrOnline said:
(-18) + (-11) ... I get overflow
You got a carry, which doesn't matter for signed number addition. The carry is used for unsigned numbers. Overflow occurs when the sign of the result is wrong (I assume you're supposed to figure out how overflow is detected).

DrOnline said:
When do I have to complement the answers?
You only complement the answers to check your work. Normally you never complement the answers.
 
  • #3
Yeah, I found a lecture video on youtube that explained that method for complementing, and it is good, I just learned MY way from my lecturer, and they both lead to the same result. Thanks for explaining it though!

Good point about the -18 + -11.. I didn't write that, you did, but I did do the operation, when I used both their 2's complements.

yeah, I am expected to understand how overflow is detected by then, this is an exam from 2008 haha, so that would be rather on the late side of things for me to understand whilst solving the exam :D

Alright, tell me when I am wrong in this statement:

Even if I am asked to solve various arithmetic using 2's complement, I will use the REGULAR binary value for the positive numbers, such as +18, and only use 2's complement for the NEGATIVE ones, such as -18. I would still comply with the demand of the task, that I use 2's complement method.

18
+ (-11)

I would use

18's regular binary
+ 11's 2's complement

Is this correct?

PS:

rcgldr said:
You only complement the answers to check your work. Normally you never complement the answers.
This is gold, exactly the kind of nuggets I am after.
 
Last edited:
  • #4
DrOnline said:
I am expected to understand how overflow is detected
Overflow occurs when the sign of the result is wrong. Depending on the operation, addition, subtraction, multiplication, or division, the test for this would be different. Perhaps start with an easy one, such as how you would detect overflow in the case of addition.

DrOnline said:
Even if I am asked to solve various arithmetic using 2's complement, I will use the REGULAR binary value for the positive numbers, such as +18, and only use 2's complement for the NEGATIVE ones, such as -18.
So far, you've only explained how to complement a number and how to add two numbers. What you were probably supposed to do is figure out how to add, subtract, multiply, and divide using two's complement.
 
  • #5
You'd think so, but we only cover doing addition using positive numbers, negative numbers, or both.

Going to re-read this tomorrow, it's almost 2 AM here.

Thanks a lot, rcgldr!
 
  • #6
Thanks again for pointing out that if I had done stuff correctly, I would never have to complement the answer.

Add that to me realizing that the MSB can be seen as an actual a negative value and not just a symbol (making it easy to figure out the magnitude of negative numbers, such as 1001 = -8+1=-7), and understanding how the operator and number symbols interact, really makes cleared up my confusion.

Thanks a lot ;)
 
  • #7
Note the addition of unsigned and two complement numbers is the same process, and that is how it's implemented on computers. Overflow is always generated based on the assumption that the numbers are signed. Carry bit is always generated based on the assumption that the numbers are unsigned. It's up to a program to choose which of these to use.

You mentioned that part of this was on an exam back in 2008, so I'm a bit confused on what you're working on now.
 
  • #8
In order to help us prepare for the exam (in 7 days), we have been issued a bunch of old exams and their solutions.

So I am going through them one by one, it's excellent training.

It's how it's done here.

I just did a bunch of calculations similar to the one we discussed above, and others with negative operators, and negative values, or both, and I got everything right. So I definitely learned something!
 
  • #9
In the case of addition, the overflow indicator bit is set if the sign bits of the two numbers to be added are the same and the sign bit of the result is not the same. This can be expressed as a boolean equation, but I don't think you'll need to know that.

I'm not sure how much of the hardware stuff you're supposed to know for the exam. As mentioned, to generate the two's complement of a number, you can invert all the bits, then increment a number. If a hardware subtract operation is going to do a complement and add, it can avoid the increment step by using a "full" adder (one with a carry bit input in addtion to the two bit inputs) on the least significant bits, then just inverting the number to be subtracted, and getting the increment done as part of the add operations by always setting the "carry bit" input on the least significant bit's "full adder".
 
  • #10
Right.. I see adders are in the curriculum, but we had no papers on it and I don't see it in any of the exam sets I have.

Currently just putting the finishing touches on things I know pretty well, improving it to knowing it perfectly, then I will go onto adders later, and read your post again. Right now it's Greek to me, because I haven't even looked at it yet. Surprised to even see it in the list to be honest.
 
  • #11
DrOnline said:
I see adders are in the curriculum, but we had no papers on it and I don't see it in any of the exam sets I have.
You probably don't have to worry about the hardware aspects such as an adder.

The part about overflow is more about the logic of how addition is done for signed two's complement numbers, so it might help to understand this. For signed two's complement numbers addition, you can only get overflow if both numbers are positive and the sum is negative or if both numbers are negative and the sum is positive. The actual process of addition treats the numbers as unsigned, so the only difference is setting the overflow indicator.
 
  • #12
When you say hardware aspect, are you talking about a logic diagram? Showing the inputs going through logic gates and exiting as outputs? If so, we do a lot of that. I'm doing OK in that department.

Or are you talking about actual implementation with electrical components. That we are not doing.
 
  • #13
DrOnline said:
When you say hardware aspect, are you talking about a logic diagram? Showing the inputs going through logic gates and exiting as outputs? If so, we do a lot of that. I'm doing OK in that department.
By hardware I must mean the logic diagrams, and since you're already doing that, it shouldn't be an issue.
 
  • #14
Don't want to brag, but I aced this exam like a boss. Thanks again!
 

1. What are 6-bit binary numbers?

6-bit binary numbers are a type of binary number that consists of six digits, with each digit being either a 0 or a 1. They are used in digital systems to represent and process data in a binary format.

2. How do you perform arithmetic operations with 6-bit binary numbers?

To perform arithmetic operations with 6-bit binary numbers, you can use the same rules as you would with decimal numbers. For addition, you add the digits from right to left, carrying over any 1s to the next column. For subtraction, you can use a method called two's complement, where you flip the bits and add 1 to the result. For multiplication and division, you can use the same methods as decimal numbers, but with the added step of converting the final result back to 6-bit binary.

3. Can you convert 6-bit binary numbers to decimal numbers?

Yes, you can convert 6-bit binary numbers to decimal numbers by using the place value method. Each digit in a 6-bit binary number corresponds to a power of 2, starting from 2^0 on the right. You can multiply each digit by its corresponding power of 2 and then add all the results together to get the decimal equivalent.

4. What are some common mistakes when performing arithmetic operations with 6-bit binary numbers?

Common mistakes when performing arithmetic operations with 6-bit binary numbers include forgetting to carry over 1s when adding, forgetting to add 1 in the two's complement method for subtraction, and forgetting to convert the final result back to 6-bit binary when multiplying or dividing.

5. How are 6-bit binary numbers used in computer systems?

6-bit binary numbers are used in computer systems for data processing and storage. They can represent a range of values from 0 to 63, making them useful for representing things like characters, symbols, and instructions in computer programs. They are also used in digital circuits and processors for performing calculations and making decisions based on binary logic.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
16K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
19K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
12K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
4K
  • Programming and Computer Science
Replies
1
Views
3K
Back
Top