I wrote: > To perform the division, I'd take the dividend and multiply it by > 100, then divide it by the already-multiplied-by-100 divisor using > an integer 24-bit/16-bit divide routine. > > The quotient will be 100 times too large, of course... If you > don't want to leave it that way, you can divide it by 100 to get > the real answer. and myke predko replied: > Actually, an easier way to do it is to multiply by the fraction of > 256/65356 and then take off the 256/65356. > > ie, for the above example, 4.35 can be represented as: > > 256 / 4.35 = 59 > = 0x03B > > 457 * ( 256 / 4.35 ) / 256 > = 457 * 59 / 256 > = 0x01C9 * 0x03B / 256 ; Putting the Numbers in > ; Hex = 0x06953 / 0x0100 > > Division by 256 is pretty easy (just cut off the last two hex > digits), giving you the result: > > 0x069 > = 105 Myke: Good advice, but your method gives an integer result and a remainder modulo 256... Ian needed an integer result and a remainder modulo 100. If you look at what's required to convert your remainder to the form he wanted, I think you'll discover that the method I proposed is a little faster. > Note this algorithm only really works when the divisor is known. Which is another reason for the method I suggested... Ian's original message implied that both his dividend and his divisor were variable. -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - Vista, California === === Custodian of the PICLIST Fund -- For more info, see: === http://www.geocities.com/SiliconValley/2499/fund.html