Hi all Here is some code char prev_ch; unsigned int chksum_read; chksum_read += (WORD)prev_ch*256; chksum_read += (unsigned int)prev_ch<<8; if prev_ch has a value of 0xDB after one of of the two above statments cheksum_read is 0xDA00 instead of 0xDB00. Can anyone explain where I am going wrong?
What is your definition of WORD? As I've said many times before, WORD (and, hence, things like DWORD, etc) is a poor type name because it tells you neither its size nor its signed-ness. It would be far better to choose a name that explicitly shows both. I use: U32 - Unsigned 32 bits S32 - Signed 32 bits U16 - Unsigned 16 bits S16 - Signed 16 bits etc.