On Wed, 8 Jul 2009, Olin Lathrop wrote: > Gerhard Fiedler wrote: > > float x; > > int y, z; > > > > int temp; // Only needed to "trick" the compiler > > temp = y / z; // into doing what I want. > > x = temp; > > > > I don't like this anymore than I like the C style automatic promotions. > > As you said, yucc. For any of you that might be interested, Pascal solves > this in a nice way by having two divide operators, "/" and "div". "/" > always produces a floating point result, whether performed on integers or > not. Div always does a integer divide, can only be performed on integers, > and produces a integer result. This scheme provides both the necessary > information to the compiler and good readability in the source code. Likewise FYI: XCSB decides on which division operator to use depending on where the result is to go. So: float x int y, z x = y / z would use a floating point division because the expected result is a floating point. If you wanted to use integer division you would write: x = (int)(y / z) This actually tells the compiler that you want to produce an integer as the result of the division. Friendly Regards Sergio Masci -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist