If you expect "char" to be signed, use "signed char". C does not specify whether plain "char" is signed or unsigned. On Mon, 18 Sep 2006, Kenneth Lumia wrote: > I am either making a really stupid error, or there > is a bug in the C18 compiler (PIC18F4620). I'm attempting > to cast a variable from 8 bits to 32 bits and it appears that the > sign is not being properly extended. Just to really annoy > me, I tried it in VC++ and it works correctly. I've > tracked the "bug" down to the following simplified code: > > typedef char INT_8; > typedef long INT_32; > > void main() > { > > INT_32 offset; > INT_8 temp; > > > temp = -5; > > offset = (INT_32)temp; //VC++ correctly reports 0xffff fffb > //C18 reports 0x0000 00fb > > } > > Is it me or the compiler? > > Thanks, > > Ken > ________________________________________ > "Well that never happened in any of the simulations" > klumia@adelphia.net > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- John W. Temples, III -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist