??? 10/29/05 13:41 Read: times |
#103113 - Question about 2's Complementary Code |
From ADI's app note,
http://www.analog.com/UploadedF...EB_prb.pdf p17 the 16bits 2's true code is abtained from 2's complementary code through the algorithm below: int Code; if( Code <= 0x7fff) //positive ; else { //negative Code &= 0x7fff; Code -= 0x7fff; } Is it right ? I think 0x7fff should be 0xffff !? Is there any problems with the program below? int Code; if(Code <= 0x7fff) //positive ; else { //negative Code &= 0x7fff; Code = ~Code; Code += 1; Code &= 0x7fff; //to remove the higher disturbing bits } the last program was tested, and it works well under C++ Builder 6, but the first one does not work! |
Topic | Author | Date |
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 |