>Mel and Carol Patrick wrote: >>1. I'm looking for the fastest way to do a SQR root. I tried the normal FB >>square root function SQR(var) and its not bad but its slower than the USR >>_sqRoot(var) that returns a long int. >> I am using the USR _sqRoot >>function as it works faster than the other SQR function. > >Robert wrote : > >My routine below is a little faster and rather more serviceable than USR >_sqRoot, but considerably uglier. Timings for square roots of numbers 1 to >a million:- > >FN SquareRoot& 145 ticks >USR _sqRoot 197 ticks >SQR 549 ticks > [code snip] (if you didn't get this code, get it, its great) Its WAY faster! Slightly untidy yes, but I didn't touch it, just pasted it into the area I wanted and bingo, it worked perfectly. Thanks! >>2. Is it also faster to use the toolboxs DeltaPoint or do the calcs myself? >Anyway why not paste this in and see for yourself... [second code snip] Again, 1/3 the ticks to do it myself and forget about using Deltapoint. Great! Here's something else I found (accidently) : FOR j&=1 TO _numTrials diffh=aPt.h% -bPt.h% diffv= aPt.v% -bPt.v% 'total1&=diffh*diffh:' need for speed 1 total1&=diffh^2:' need for speed 2 NEXT Since I am working out lengths, I need to take the number and mulitply it by itself. So being a rather bright chappie that I think I am (okay humour me), I just used ^2 after the variable. WRONG. I ran the timing test, or rather started it, went and made coffee, came back, it was just about done. Sheesh. So now, sitting and sipping coffee, I changed the line to be a boring, simple var*var. The difference was incredible. The tick count barely increased by 30% and thats in the 3 million cycles I was testing it at. Methinks I shall avoid using the ^ exponentiation in future. My THANKS VERY MUCHLY! Mel Patrick - theWabbitGuy - mel@... mailto:mel@... http://www.intergate.bc.ca/business/mel