MCB, If you're using integer exponents, it's usually faster to multiply than to raise to a power as shown in this code:
If possible, try to make calculations integer types. You may be able to pre-calculate values that you reuse, even transcendental ones. How you temporarily store your intermediate values can matter too. If you'd like to post example code from an "innermost loop", I'd bet someone here could recommend significant optimization possibilities.
Code:
#COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG LOCAL t, t2 AS QUAD, ii, x AS EXT '------------------- x^4 ----------------------- TIX t FOR ii = 1 TO 10000000 x = ii ^ 4 NEXT TIX END t TIX t2 FOR ii = 1 TO 10000000 x = ii * ii x = x * x NEXT TIX END t2 ? STR$(t / t2, 4) & " x faster" '=============================================== '------------------- x^2 ----------------------- TIX t FOR ii = 1 TO 10000000 x = ii ^ 2 NEXT TIX END t TIX t2 FOR ii = 1 TO 10000000 x = ii * ii NEXT TIX END t2 ? STR$(t / t2, 4) & " x faster" '=============================================== WAITKEY$ END FUNCTION
Comment