Forum Discussion
Altera_Forum
Honored Contributor
16 years ago2's complement consideration
Hello everyone! I have some considerations about the implementation of twos complement in a filter/decimation design. The ADC used in the design is AD7401, which had also been discussed ea...
Altera_Forum
Honored Contributor
16 years agoThere are two things: Signed vs unsigned numbers and two's complement notation. Only signed numbers can have negative values. The value/magnitude of a 2's compliment negative number is found by complement and add 1. The msb of the number is the sign bit.
There are other bases for complement(one, nines, tens, etc). If the ADC can have a negative output, then is already in complement form -- no doubt 2's, not 1's. If it can only have positive output, then it will have either unsigned output, or the msb will always be 0 resulting in an unused msb in the output. If for some reason you want to convert a positive output to a negative value, complement and add 1; Be aware that there may be unexpected results if the msb is 1. If I remember correctly complement and add1 effectively does the subtract of 32768.