On December 31, 2005 12:20 pm, WH Tan wrote: > On 1/1/06, Herbert Graf wrote: > > checksum = checksum + buffer[i]*256 + buffer[i+1]; > > > > I've also tried other "lines" like: > > checksum += buffer[i]*256 + buffer[i+1]; > > checksum += buffer[i]<<8 + buffer[i+1]; > > checksum += (unsigned long)(buffer[i]*256 + buffer[i+1]); > > I'm not sure but try this: > > checksum = checksum + (unsigned long) buffer[i]*256 + buffer[i+1]; > > or > > checksum += (unsigned long) buffer[i]<<8 + buffer[i+1]; I haven't used C18, but some compilers are really twisted! For example, my DOS 8088 compiler has trouble with values beyond 16bit since the compiler doesn't really know how to work with 32bit values, so you end up having to mask bits just to get a result. If you still have trouble, try something like this: (unsigned long)(checksum += (((buffer[i]<<8) & 0xff00) | buffer[i+1])); -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist