MATHEMATICS
Use bitshifting
<< 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 >>
I would have thought that bitshifting, ie:
total1&= diffh<<1
would have been faster than a multiply, no?
Its faster if the number was *2 or 4, 8 etc. But you can't bitshift to multiply something like 9 * 3 (okay probably Mars could, but I'm not going to). Thanks to Roberts SQR function and some customizing of my own, the routine is whizzing along so that the end user doesn't even know the difference when using or not using this option.
Think I am going to go curl up with IM and bone up on regions. My pillow will be a good intersecting region...;)
I'm sure it would be faster, but it would also give very different results (except when diffh = 2). "diffh<<1" is the same as diffh*2, not diffh^2. 8)
<< But you can't bitshift to multiply something like 9 * 3 (okay probably Mars could, but I'm not going to).>>
CLEAR LOCAL MODE
LOCAL FN ShiftMultiply&(a&, b&)
DIM product&
WHILE b&
IF b& AND 1 THEN product& = product& + a&
b& = b& >> 1
a& = a& << 1
WEND
END FN = product&
This is roughly 13 times slower than ordinary multiplication. It might be marginally faster if written in assembly language.
