That's an improvement. It would be even better if it actually worked! I hope these fixes make it what you had in mind. /* signed */ int raw; void convert() { inches = f1 = f10 = -1; while (raw >= 0) { raw -= 1200; f10++; } raw += 1200; while (raw >= 0) { raw -= 120; f1++; } raw += 120; while (raw >= 0) { raw -= 10; inches++;} tenths = raw + 10; } This, with driving code, compiles to exactly the same size as my version but would be significantly faster. The big win is in checking for a negative number as opposed to comparison to a constant. On the other hand the algorithm is a bit obscured, prolly not too bad in such a short run of code. ...rob Walter Banks wrote: >The comparisons of raw to a constant requires a subtract that can be folded >into the raw-= constant > > while (raw >= 1200) { > raw -= 1200; f10++; > >The following code does this and should be significantly shorter and almost >twice as fast > >Walter Banks > >void convert1() >{ > > inches = f1 = f10 = -1; > > while (raw >= 0) { raw -= 1200; f10++; } > > while (raw < 0) { raw += 120; f1++; } > > while (raw >= 0) { raw -= 10; inches++;} > > tenths = -raw; >} > --- robert a moeser http://www.piclist.com/member/ram--000a PIC/PICList FAQ: http://www.piclist.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body