I've been reading over a couple of questions/answers here:twos-complement-in-pythonis-twos-complement-notation-of-a-positive-number-the-same-numberSomeone gave some sample code to create a two's complement of a number:def twos_comp(val, bits): """compute the 2's compliment of int value val""" if( (val&(1<<(bits-1))) != 0 ): val = val - (1<<bits) return valIn addition someone defined two's complement as thus: Two's complement notation uses the n-bit two's complement to flip the sign. For 8-bit numbers, the numbe...Read more

i'm doing an exercise on two complement, the question sound like this:Solving 11base10 – 11base10 using 2’s complement will lead to a problem; by using 7-bit data representation. Explain what the problem is and suggest steps to overcome the problem.i got 0 for the answer because 11-11=0, what problem if the answer is 0?and is there a way to overcome it?...Read more

If we use seven-bit two's complement binary representation for integers, what isThe number of integers (things) that can be represented in this way?The smallest (most) negative integer that can be represented in this way?The largest positive integer that can be represented in this way?This is a CS homework question that I am having trouble answering and explaining. Any help would be appreciated....Read more

Why do we have to use complements (e.g 2's complement, 10's complement etc) in computer systems to perform subtraction operations? Just like circuits for addition operations(adders) , we do have circuits for subtraction(subtractors), right?...Read more

If we use seven-bit two's complement binary representation for integers, what isThe number of integers (things) that can be represented in this way?The smallest (most) negative integer that can be represented in this way?The largest positive integer that can be represented in this way?This is a CS homework question that I am having trouble answering and explaining. Any help would be appreciated....Read more

I have some real data. For example +2 and -3. These data are represented in two's complement fixed point with 4 bit binary value where MSB represents the sign bit and number of fractional bit is zero.So +2 = 0010-3 = 1101addition of this two numbers is (+2) + (-3)=-1(0010)+(1101)=(1111)But in case of subtraction (+2)-(-3) what should i do?Is it needed to take the two's complement of 1101 (-3) again and add with 0010?...Read more

I am using 2' complement to represent a negative number in binary formCase 1:number -5According to the 2' complement technique:Convert 5 to the binary form:00000101, then flip the bits11111010, then add 100000001=> result: 11111011To make sure this is correct, I re-calculate to decimal:-128 + 64 + 32 + 16 + 8 + 2 + 1 = -5Case 2: number -240The same steps are taken:11110000000011110000000100010000 => recalculate this I got 16, not -240I am misunderstanding something?...Read more

So I want to represent the number -12.5. So 12.5 equals to:001100.100If I don't calculate the fraction then it's simple, -12 is:110100But what is -12.5? is it 110100.100? How can I calculate this negative fraction?...Read more

I am confused on how to do conversion from one's complement to two's complement.Suppose we have 10101101 in one's complement. How to convert it to two's complement?Thanks...Read more

I am not sure this is the proper section of the forum, in case please just let me know.I am studying Computer Organization and Design, and the legendary Patterson & Hannessy states that "One's complement adders did need an extra step to subtract a number and hence two's complements dominates today".What is the extra operation that does an one's complement require?...Read more

I have looked through the ISA spec and searched the internet for the answer to this, but I could not find it.In the RISC-V ISA, should negative numbers be represented with one's complement or two's complement? Or, is this decision left to implementors?The reason I ask is that I am writing an RV32I simulator, and this would affect how I store negative numbers in the simulated memory, for example....Read more

Can you please explain the solution for the below problem?I do not understand how we arrive to this conclusion −2^(n−1) + 2^(n−1) −1 −xEspecially I am confused why we need to subtract xYou obtain the representation for a negative number in two’s complement method by takingone’s complement of a number and then adding one. Why does it work? What is the key idea behind two’s complement representation?Answer: The key idea is to treat the sign bit as a value with a negative sign. In a n-bit representation,the value of the sign bit is -2^n1 .When you...Read more

What is the maximum and minimum values can be represented with 5-digit number that is assuming 2's complement representation?do I find the the min and maximum value of 5-digit numbers, which are 00000 and I'm not sure what the max is. Then convert to two's complement? This sounds stupid, but it's the only one I can come up with... my last question is: What is the minimum register length in a processor required to store values between –EA(base16) and24(base16) assuming they are stores using the 2’s complement format? I'm not sure how to attack ...Read more

The question is to find the 2's complement of the binary number (-00101.110) in 8 bits.So I don't understand what to do with the fractional part. I think the 1's complement will be 11010.001Is 11010.010 the 2's complement? And are these the 8 bits that I need as my final answer of the 2s complement of -00101.110?...Read more

When storing a negative number with one's complement before you add the 1 for two's complement, why are all the bits other than the sign inverted? I suppose It would just be simpler if the only thing different was the sign. The only reason I can think of is it somehow make it easier for the computer....Read more