Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/31/05 17:46
Read: times


 
#103201 - 1's and 2's complement
Responding to: ???'s previous message
Adam, I think you’re partially right.

In the datasheet of the AD5934 on page 22 it show data the data from this converter is in 2’s complement.

In the program on page 17 of your reference it also written that it is 2’s complement and that 0x7FFF is 32767. So far I agree.

So in a word (16 bits) data <= 0x7FFF is positive and >=0x8000 is negative


The conversion on page 17 is wrong, I think.

0xFFFF = -1 the conversion on page 17 gives us:

0xFFFF & 0x7FFF = 0x7FFF – 0x7FFF = 0 (1’s complement)


It should be: invert data, add 1 for a 2’s complement conversion

0xFFFF ! = 0 + 1 = -1 because it was >= 0x8000 it is negative

0x8000 ! = 0x7FFF + 1 = -32768 because it was >= 0x8000 it is negative

Like your example


Hope this helps to clear things up


List of 9 messages in thread
TopicAuthorDate
Question about 2's Complementary Code            01/01/70 00:00      
   Why?            01/01/70 00:00      
      ok! if it is not suitable,delete my post            01/01/70 00:00      
         Just wondreing...            01/01/70 00:00      
            sorry, I miss understanding your meaning            01/01/70 00:00      
   Read the datasheet carefully!            01/01/70 00:00      
      size of int are 4 bytes in CB6            01/01/70 00:00      
   1's and 2's complement            01/01/70 00:00      
      yes, it is wrong!            01/01/70 00:00      

Back to Subject List