# A confusion regarding signed representation of binary numbers

Suppose I have an ADC that converts the analog input samples to 4-bit signed binary numbers. The resolution of the ADC is 0.5V. Since the binary o/p is of sign magnitude representation, the MSB has no magnitude and the i/p range of the ADC is from -3.5 to +3.5.

However there are two representations of 0 (i.e. if the i/p is 0V). One of them is 0000 and the other 1000. That means for 0V, I have two different encoding levels. How do I represent that on the voltage characteristics? Its pretty clear to me for positive values, how the characteristics is going to be like - Where do I put the level 1000? Obviously 0000 and 1000 cannot be present at the same place.

Also, if the i/p is 2.7V, the encoded o/p is 0101. Similarly for an i/p of -2.8V, going by the previous logic, shouldn't the o/p be 1101?

This is the question that got me thinking about it - • You should say "sign-magnitude" instead of "signed representation of binary numbers" because there are several signed representations of binary numbers, and the most common one is two's-complement, which is different from sign-magnitude. – user253751 Feb 25 '18 at 0:54
• Apologies. I have corrected it. – Rohan Singh Feb 25 '18 at 1:31

In 2's complement, 1000 does not represent 0, but rather -8. So, in your ADC (or DAC), you would use it to represent -4.0 V.

More precisely, in an ADC, each code would represent the center of its range:

Code     ADC input            DAC output
----  ----------------        ----------
0000: -0.25 to +0.25 V          0.00 V
0001: +0.25 to +0.75 V         +0.50 V
0010: +0.75 to +1.25 V         +1.00 V
0011: +1.25 to +1.75 V         +1.50 V
0100: +1.75 to +2.25 V         +2.00 V
0101: +2.25 to +2.75 V         +2.50 V
0110: +2.75 to +3.25 V         +3.00 V
0111: greater than +3.25 V     +3.50 V


Similarly, in the negative direction, you would have:

Code     ADC input            DAC output
----  ----------------        ----------
1111: -0.25 to -0.75 V         -0.50 V
1110: -0.75 to -1.25 V         -1.00 V
1101: -1.25 to -1.75 V         -1.50 V
1100: -1.75 to -2.25 V         -2.00 V
1011: -2.25 to -2.75 V         -2.50 V
1010: -2.75 to -3.25 V         -3.00 V
1001: -3.25 to -3.75 V         -3.50 V
1000: less than -3.75 V        -4.00 V


A sign-magnitude ADC would be slightly different. The positive direction would look the same:

Code     ADC input            DAC output
----  ----------------        ----------
0000: -0.25 to +0.25 V          0.00 V
0001: +0.25 to +0.75 V         +0.50 V
0010: +0.75 to +1.25 V         +1.00 V
0011: +1.25 to +1.75 V         +1.50 V
0100: +1.75 to +2.25 V         +2.00 V
0101: +2.25 to +2.75 V         +2.50 V
0110: +2.75 to +3.25 V         +3.00 V
0111: greater than +3.25 V     +3.50 V


But in the negative direction, you would have:

Code     ADC input            DAC output
----  ----------------        ----------
1001: -0.25 to -0.75 V         -0.50 V
1010: -0.75 to -1.25 V         -1.00 V
1011: -1.25 to -1.75 V         -1.50 V
1100: -1.75 to -2.25 V         -2.00 V
1101: -2.25 to -2.75 V         -2.50 V
1110: -2.75 to -3.25 V         -3.00 V
1111: less than -3.25 V        -3.50 V


It's possible that the range around zero might be split into two:

Code     ADC input            DAC output
----  ----------------        ----------
0000:  0.00 to +0.25 V          0.00 V
1000: -0.25 to  0.00 V          0.00 V

• No no, I'm not talking about 2's complement. I'm talking about signed representation of binary numbers. In 2's complement there's only one representation of 0 and that is 0000. There's no problem in 2's complement representation. – Rohan Singh Feb 24 '18 at 15:58
• The ADC datasheet will have a section what the number format is. I doubt it is anything other than two's complement. – Oldfart Feb 24 '18 at 16:02
• Two's complement is THE signed representation of binary numbers. One of the alternatives is sign and magnitude. – filo Feb 24 '18 at 16:02
• @filo, that's not true with ADCs. Even if you put it in big letters. Sign/value devices are common. – TonyM Feb 24 '18 at 16:11
• @filo - you are mistaken. Two's complement is not the signed representation, it is mere a representation among several. It is by no means universally chosen, even today, and so it may not be safely assumed - especially when dealing with things that are not CPUs. – Chris Stratton Feb 24 '18 at 17:37