On May 9, 2008, at 6:27 PM, John Coppens wrote: > I believe this is not a precise division. What is being done is > multiply > really by 1/14 in decimal, or 0.071... You selected a precision of 16 > bits (?), so the error will probably be in the order of 1. It's quite > probable that the first one fails. Right, that's PART of it. But multiplying (floatingpoint) by (1.0/16 + 1.0/128 + 1.0/1024 + 1.0/8192 + 1.0/65536) over the input range (1..65535) gives only 1/3 the number of errors (about 7000) as adding the set of integer divisions. Note that this point is about as far as it makes sense to take the binary fractions; for the 16bit input, anything smaller than i/65536 is going to be zero anyway; that's one of the factors that led me to expect better results. :-( > The error will always be +/- 1, but if you selected 16 bit precision, > that means only an error of 1 in 4000 or so (65536/14). Which, if you > look to replace fractional division by a simple algorithm, is quite > good. Sounds good, doesn't it? But 14/14 = 0 is 100% error ! It seems like a similar algorithm ought to be able to do better. BillW -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist