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. Mel, 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 LOCAL FN SquareRoot&(a&) ' Replacement for USR _sqRoot (a&) which has three faults:- ' 1. It crashes for a&=_Maxlong/2 ' 2. It gives wrong answer for a&>_Maxlong/2 ' 3. it gves "high-by-one" answers in many cases, e.g. USR _sqRoot(15)=4 ' This routine works for all values of a& unsigned (0-4294967295) ' and is slightly faster than USR _sqRoot. It DOES NOT WORK on 68000 machines. DIM root& ` move.l ^a&,d3 ` move.l d3,d0 ` beq.s SqDone ; skip if 0 ` move.l d3,d1 `ApprLoop lsr.l #1,d0; init root& by halving number of digits in a& ` lsr.l #2,d1 ` bne.s ApprLoop ` addq.l #1,d0 ; force non-zero ` move.w #4,d7 ; max loop count `SqLoop ; iterate root& = (a&/root&+root& )/2 ` move.l d0,d5 ; copy of root& ` clr.l d1 ; hi of a&=0 ` move.l d3,d2 ; lo of a& ` dc.w $4C40,$2401; DIVU.L D0,D1:D2 d2.l= d1(hi) d2(lo)/d0.l; d1.l=remainder ` add.l d2,d0 ; a&/root&+root& ` lsr.l #1,d0 ; / 2 ` cmp.l d0,d5 ; equals old? If so, we are done ` dbeq d7, SqLoop ; branch back if <> old and loop count >=0 ` move.l d0,d2 ; prepare for root&*root& ` dc.w $4c00,$2401 ; MULU.L D0,D1:D2 d1(hi) and d2(lo)=d0.l*d2.l ` cmp.l d2,d3 ; compare with a& ` bge.s SqDone ` subq.l #1,d0 ; adjust to prevent "hi-by-one error" `SqDone move.l d0,^root& END FN=root& >2. Is it also faster to use the toolboxs DeltaPoint or do the calcs myself? Consultation with learned philosophers and necromancers suggests that the answer to your question is likely, or even sure to be, "yes". Anyway why not paste this in and see for yourself... DIM aPt.4, bPt.4 _numTrials=3000000 WINDOW 1 CALL SETPT(aPt, 100,-1) CALL SETPT(bPt, 10,100) now&=FN TICKCOUNT FOR j&=1 TO _numTrials diff&=FN DELTAPOINT(aPt,bPt) NEXT now&=FN TICKCOUNT-now& PRINT FN HIWORD(diff&), FN LOWORD(diff&) PRINT "FN DELTAPOINT" now&"ticks" now&=FN TICKCOUNT FOR j&=1 TO _numTrials diffh=aPt.h% -bPt.h% diffv= aPt.v% -bPt.v% NEXT now&=FN TICKCOUNT-now& PRINT diffv, diffh PRINT "direct calc" now&"ticks" DO: UNTIL FN BUTTON >3. Next in my list > >4. And last, why is I'll pass on those two items. Robert