questuk wrote: > > Does anyone have a routine that divides a 16 bit number by another > 16 Bit number, and gives the result to 2 decimal places > (i.e.answer= 1663.65). I have looked all over the web and this site > and cannot find one. I have looked at Microchip AN575 but sorry it > lost me! > Assume the number is stored in memory as: (MS Byte)(LS Byte) There is a binary point (decimal point equivalent for binary numbers) to the right of the LS byte of the number. So if we consider the number as: (MS Byte)(LS Byte).(00000000) which is a 24-bit binary number with the least significant bit representing the number 1/256 (= 0.00390625 in decimal) or about 2.5 decimal places of precision. Dividing the 24-bit number by a 16 bit number (using any of the appropriate techniques) results in a number that should fulfill your requirements. Consider 51966 divided by 64: 51966 = 0xCAFE = 1100101011111110 = 1100101011111110.00000000 I chose the 64 for simplicity, to show how this works, since dividing by 64 is just a right shift of 6 bits, therefore just like moving the binary point left 6 bits, 1100101011111110.00000000/64 = 1100101011.11111000000000 of course in memory this would look like (11001010)(11111110).(00000000) before divide (00000011)(00101011).(11111000) after divide which is 512+256+32+8+2+1+(1/2)+(1/4)+(1/8)+(1/16)+(1/32) or 811.96875 David W. Gulley Destiny Designs -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads