On Thu, 5 Jun 2003 16:00:46 +0200, you wrote: >I know a lot can be optimized, but unfortunately it's not one of my >strong points. :) I tried to rewrite the formula, but none of the other >forms gave me anything that was more efficient computationally. > >The formula calculates acceleration, measured by a digital >accelerometer. The T1's en T2's are intervals whose variation is a >measure of acceleration, relative to calibrated measurements as T1Cal >(ZCal) and T2Cal. So a division like T2/T2Cal will always be close to 1. >The output y is a measure for the acceleration. This will later be used >in arcsin, sin and cos calculations. The result of those are arctan'ed; >that's why I need precision. > >The range of the variables is about 0-20000, so their product is 4x10^8 >worst case. which is pretty much 32bit for my taste (ok it's 29, or 30 >with sign; close 'nuff :)). > >Anyway, y is always between -2 and +2. I do believe I need floats, but I >may be mistaken. ..so use a multiplying factor to the numerator before the division, to = scale up the output value to give whatever precision you need.=20 =20 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu