Bob Blick wrote: > On Tue, 30 Mar 2010 14:38:34 +1300, "Russell McMahon" said: > >> I've read what the others said, and if the following was the case >> you'd expect it to have been said. This is somewhat implicit in at >> least one reply. >> >> As >> foo+bar >> >> is capable of overflowing an 8 bit word, then at least bat needs to be >> int for safety. >> > > Right, except if bat is a checksum and it's an unsigned char because you > designed it that way :( > > So much for C letting you shoot yourself in the foot if you so choose. > > Actually I do understand the ANSI rules, I just forgot the ways HiTech > decides to apply them or forget them, and when they wrote my old manual > they hadn't written that part yet. > > Cheers, > > Bob > > if in doubt... in all languages and projects If it's not the same type cast or explicitly convert. letting the compiler do it and making assumptions will bite you eventually. What if you use a different compiler or want to translate to another language. If your compiler has a "warnings" feature for automatic promotion or truncation turn it on. -- Mike aka Watty. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist