Usually operation on the binary mode is faster than that on the decimal mode.
How faster depends on CPU. The decimal operation mainly uses integer operation of CPU, while the binary operation uses floating point operation of CPU or FPU.
Windows edition of Decimal BASIC uses RichEdit control of Windows API to display the output of PRINT statements.
Some program takes most time to display to the screen.
When a program has mass of output, it is effective to output to a file.
Example. Sieve of Eratosthenes (executed on Windows XP)
output to the screen | output to a file |
120 DIM s(100000) 125 LET t0=TIME 130 MAT s=ZER 140 FOR i=2 TO 100000 150 IF s(i)=0 THEN 160 PRINT i 170 FOR j=i^2 TO 100000 STEP i 180 LET s(j)=1 190 NEXT j 200 END IF 210 NEXT i 215 PRINT TIME-t0 220 END |
120 DIM s(100000) 125 LET t0=TIME 130 MAT s=ZER 135 OPEN #1:NAME "eratos.txt" 136 ERASE #1 140 FOR i=2 TO 100000 150 IF s(i)=0 THEN 160 PRINT #1:i 170 FOR j=i^2 TO 100000 STEP i 180 LET s(j)=1 190 NEXT j 200 END IF 210 NEXT i 214 CLOSE #1 215 PRINT TIME-t0 220 END |
34.4 seconds | 0.84 seconds |
When data in DATA statements are compiled, Decimal BASIC takes much time to read them from the RichEdit control. If a program has much data, they should not be written in DATA statements but be read from a file.
Array parameters in Full BASIC are passed by reference on subprograms and picture definitions, and by values on function definitions.
As it takes much time to copy arrays, it is recommended that function definitions are rewritten to subprograms. However note that when an array parameter or its element is changed in a subprogram, this change effects the argument. Thus if some array parameter is changed in a function definition, this function definition can not be rewritten to a subprogram.
Removing the check for "indent" on auto-correct option decreases somewhat compiling time.
BASIC Accelerator executes BASIC programs fast by translating them to Pascal programs. Most of BASIC programs that can be executed on the binary mode can be executed fast by BASIC Accelerator.