On Feb 10, 2009, at 8:49 PM, Forrest W Christian wrote: > Is there a reference somewhere which isn't written in computer-science > speak which explains what is really going on in a typical C compiler > when you do something like: > > i=c*2.342; > > Where i is 16 bit, and c is 8 bits... and how to ensure that the > compiler produces a 16 bit result, after doing floating point math > during a multiply? > > i=c*c is also interesting at times, and so on. > > So, could anyone point me toward a reasonable explanation (and don't > tell me to go read the standard, as I've tried :)... I don't know that there IS a reasonable explanation for this. C has it's rules, but I'm not sure they're sensible. So you shouldn't DO this and let those rules take control, but instead, if you MUST mix variable types like this, you should make all the conversions completely explicit: i = (int16_t) ((float)c * 2.342); BillW -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist