On Sun, 1 Mar 1998 23:43:02 -0800 Hans de Vries writes: >The calculation is: > > Value*128 > --------- > Range > >Value = 1-255 >Range = 1-255 > >The result is an 8-bit. The result may not fit in 8-bits. If 128/Range is greater than 1 (i.e. Range is less than 128), the result will be larger than 255 for Value inputs of 255. >I know I can do this with an 16x16 division, but the code I have is >too >big and too slow. Division by an 8-bit number is relatively easy with a standard long-division algorithm, since the subtract-and-test operation is only 8 bits. To expand the size of the numerator, just execute more loops. Expanding the size of the denominator beyond 8 bits requires a multiple-precision subtract routine. I have a funny feeling this can be solved with a >little trick, If the result needs to be computed really fast for new inputs of Value (while Range stays the same), precompute 128/Range then multiply Value by it each time (slip the result a byte or more to the left so precision is maintained). _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]