on Apr 28th, 2015, 9:30pm, David Williams wrote: REM Division table needed for ARM BBC BASIC version REM (using this is probably slower for BB4W) |
|
I tried to benchmark that:
Code: DIM divTbl(40000)
FOR I% = 1 TO 40000
divTbl(I%) = 1/I%
NEXT I%
TIME = 0
FOR J%=1 TO 100 : FOR I%=1 TO 40000 : A = divTbl(I%) : NEXT : NEXT
PRINT "Using lookup table: ";TIME
TIME = 0
FOR J%=1 TO 100 : FOR I%=1 TO 40000 : A = 1/I% : NEXT : NEXT
PRINT "Using division : ";TIME
Which gave (using BB4W v6.00a):
Code:Using lookup table: 311
Using division : 270
So although the table is a little slower, there's not much in it.
Richard.