-95 to 12 Bit Binary Signed Integer
Question. Find the Value of the 12-Bits Required to Represent the Signed Integer: -95 So Converting That to Binary Would Be: 01011111 but to Represent That as...
Question. Find the value of the 12-bits required to represent the signed integer: -95
So converting that to binary would be:
01011111
But to represent that as a 2's compliment signed binary number, I would need to make the first bit a 1 (representing negative or -), then the proceeding bits (not including the most right 1) are inverted, 0 becomes 1, 1 becomes 0. I get:
10100001
Is this correct? When it says, signed integer that means 2's compliment and representing positive negative with the first bit either being 0 or 1 respectively?
1 Answer
First off, you have 95 represented as only 8 bits. To convert to 12-bit unsigned, just prepend the appropriate number of 0's (0000 0101 1111). If the number was signed and you wish to convert it to more bits, you would need to prepend the correct sign.
Going from binary to twos complement can be done by following steps:
1. 95 to 12-bit binary: 0000 0101 1111
2. Flip the bits: Ex) 0000 0101 1111 --> 1111 1010 0000
3. Then add one: Ex) 1111 1010 0000 + 0000 0000 0001 = 1111 1010 0001 = -95
So yes, the answer you have is correct. You can check things like this by googling a binary/twos complement calculator. Ex:
When it says, signed integer that means 2's compliment and representing positive negative with the first bit either being 0 or 1 respectively?
Yes, signed integer assumes that the first bit represents the sign of the binary number.