Cole Christopher J wrote: > > Hmm, you haven't understood what I was trying to get across, > > I have to scale a value in the range 0-359 to within the range 0-114. > > My 0-359 value is in the form of 3 bytes - representing hundreds, tens, units - so, I have to multiply the hundreds value (of the 0-359 value) by 31.7, multiply the tens value by 3.17 and the units value by 0.317. You can do this very quickly if you don't mind a small error of about 1/3 of a percent. Goal: 360 -> 115 Method: (num is range 0-359) a = (num*2) a+= (num*16) a+= (num*64) (that involved 3 shifts and 2x 16bit adds and gives result of num*82, then;) result = (a/256) (that just discards lower byte and the result is in the upper byte!) All done, result is 115.31 (worst case) when should be 115.00 but is always less than one digit error so is probably acceptable. -Roman -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu