I'm supposed to convert the following negative numbers to 8-bit binary using both (i) ones complement, and (ii) twos complement:
-76
-203
-18
-177
I know how to do -76 and -18...
• -76
In binary (positive): 01001100
i) 10110011
ii) 10110100
• -18
In binary (positive): 00010010
i) 11101101
ii) 11101110
But I don't know how to approach the other two since the range for 8 bits is -128 and 127... Heeelppp
Thanks in advance
Related
What is the most negative number we can represent with 7-bit two's complement representation?
With 7-bits of 2's complement, it could range from -64 to 63. (traditionally, 7 bits can only go up to 2^n-1 which is 128 but MSB is reserved for sign, so we could have 6 bits to represent the data. We will be getting 64 positive and 63 negative values and answer should be -64, 63.)
No, because in two's complement, the most significant bit is the sign bit. 0000001 is +1, a positive number.
That is why the range of two's complement 7-bit numbers is -64 to 63, because 64 is not representable (it would be negative number otherwise).
The most negative number is 1000000. The leading 1 tells you it's negative, and to get the magnitude of the number, you flip all the bits (0111111), then add one (1000000 = 64). So the resulting number is -64 thru 63.
I'm trying to understand what a two byte hexadecimal value would look like. As an example, we have the decimal values 41 and -73 with their two-byte binary equivalents:
dec
41 -binary: 000000 00101001
-73 -binary: 11111111 10110111
The hex should then be 29(base16) and 49(base16) respectively. How are these hex values represented in a "two byte" value. Am I doing something wrong here?
thanks
I came across the question to find out 2's complement of -32 .
how to determine in minimum no of bits how -32 is represented in 2's complements.
Is it 1100000 or 100000
Easy way to compute 2's complement is adding 1 to its 1's complement.
Using 7 bits (min for 32) 32 is 0100000, so -32 is 1011111 using 1's complement. With 2's complement, you add 1 so it becomes 1100000.
I was wondering if someone could double check my work for me real quick. If I'm given two negative numbers: -33 and -31. If I add them together what will be the result using 2's complement.
NOTE: A word length of 6-bits MUST being used for the operation.
MY ANSWER
So after doing this I computed -31 to be 100001 in 2's. I also computed -33 to be 011111 in 2's complement. When adding them together I got 1000000, however this number is 7 digits so I chopped off the higher order bit since I'm bound to a word length of 6-bits. This yields the number 000000. Which contains a sign bit of 0, meaning it would be even. However since the sum of 2 negative's cannot be even it's obviously an overflow. So I take the 2's of 000000 which is simply 000000.
So the answer should be: 0 since a buffer overflow occurred. Does this seem right to you guys? THANKS. :)
First of all: -33 + (-31) cannot be 0.
-33 is not representable in 6bit 2's complement. 01 1111b is +31 in decimal, so the addition results in 0.
So the correct answer is something like that: There is no result because -33 is an invalid number in 6bit representation.
in 7 bit 2's complement -33 = 101 1111b
110 0001
+101 1111
=
1100 0000
which is equal to -64.
So i was told that two's complement is usually to used to find complement of a number and I used it only to complement positive numbers (i.e positve --> negative conversion) however I just got an example in book which asks me the following :
Express 23, -23, and -9 in 8-bit binary two’s Complement
form
now what does that mean? 23 means -23 in binary and -23 means 23 ?
sorta confused over there
2's complement is used to represent negative numbers, which in turn, can be used to do subtraction.
23 = 00010111b
To get -23 (2's complement of 23), flip all the bits, and add 1:
11101000b + 1
=11101001b (-23)
-9 is the 2's complement of 9. 9 is
00001001b
So -9 is
11110111b (Flipping and add +1)
See also here
The representation of positive numbers in 2's complement is same as the unsigned representation. Things start to change when negative representation comes into play. So, in general, for given w bits, the numbers that can be represented in 2's complement are -2^(w-1)-1 to 2^(w-1) with the w bit being the signed bit. So since you have 8 bits you can represent numbers from -128 to 127. The 8th bit will be the signed bit, with 0 being positive and 1 representing negative.
For any positive representation of a number in binary 2's complement N the negative counterpart -N is pretty simple to find, just invert the bits, and add one. Example:
7 in 2's complement is 0111, inverting these bits gives: 1000, adding one gives 1001, which is -7 in 2's complement! Hope this helps!