A) I see where you are coming from Warren... It should be a compiler switch I think. Complain or don't complain. But I still think the editor should enforce the case in the way that VB handles it as well. In that way, you won't need to worry about whether you typed it right. The editor "fixes" it for you.
B) Just for sheets and grins I ran the sieve on my laptop and got a linear progression as well... Also did a little converting over to IBasic Pro and tested there as well. Was a little surprised (maybe I'm doing something wrong)...
Just checked Powerbasic 7 too btw...
The results were:
B) Just for sheets and grins I ran the sieve on my laptop and got a linear progression as well... Also did a little converting over to IBasic Pro and tested there as well. Was a little surprised (maybe I'm doing something wrong)...
' Ported from another Basic for benchmarking purposes... ' IBPro version def t:int def Iter:int def Count:int def i:int def prime:int def k:int def w1 as window Const ITERATIONS = 25000 OPENWINDOW w1,0,0,350,350,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main def Flags[8191]:int Print w1,"SIEVE OF ERATOSTHENES - " + str$(ITERATIONS) + " iterations" t = MilliSecs () For Iter = 1 To ITERATIONS Count = 0 For I = 0 To 8190 Flags[I] = 1 Next I For I = 0 To 8190 If Flags[I]=1 Then Prime = I + I Prime = Prime + 3 K = I + Prime While K <= 8190 Flags[K] = 0 K = K + Prime Wend Count = Count + 1 EndIf Next I Next Iter t = MilliSecs () - t move w1,0,20 Print w1,str$(ITERATIONS)+" iterations took "+str$(t)+" m/secs." move w1,0,40 Print w1,"Primes: "+str$(Count) WAITUNTIL w1 = 0 End SUB main IF @MESSAGE = @IDCLOSEWINDOW REM closes the window and sets w1 = 0 CLOSEWINDOW w1 ENDIF RETURN ENDSUB
Just checked Powerbasic 7 too btw...
' Ported from another Basic for benchmarking purposes... ' PowerBasic7 version #INCLUDE "WIN32API.INC" FUNCTION PBMAIN () DIM t AS INTEGER DIM Iter AS INTEGER DIM Count AS INTEGER DIM i AS INTEGER DIM prime AS INTEGER DIM k AS INTEGER DIM s AS STRING DIM ITERATIONS AS INTEGER DIM Flags(8191) AS INTEGER iterations = 25000 t = timeGetTime () FOR Iter = 1 TO ITERATIONS Count = 0 FOR I = 0 TO 8190 Flags(I) = 1 NEXT I FOR I = 0 TO 8190 IF Flags(I)=1 THEN Prime = I + I Prime = Prime + 3 K = I + Prime WHILE K <= 8190 Flags(K) = 0 K = K + Prime WEND Count = Count + 1 END IF NEXT I NEXT Iter t = timeGetTime () - t s = "SIEVE OF ERATOSTHENES - " + STR$(ITERATIONS) + " iterations" + CHR$(13) + CHR$(10) s = s + STR$(ITERATIONS)+" iterations took "+STR$(t)+" m/secs." + CHR$(13) + CHR$(10) s = s + "Primes: "+STR$(Count) MSGBOX s END FUNCTION
The results were:
Interations IBasic Pro BMax Beta PowerBasic7 5000 3074 m/sec 585 m/sec 1735 m/sec 10000 6159 m/sec 1103 m/sec 3265 m/sec 15000 9204 m/sec 1899 m/sec 4914 m/sec 20000 12408 m/sec 2207 m/sec 6557 m/sec 25000 15342 m/sec 2744 m/sec 8164 m/sec