Post by Psycho on Oct 23, 2008 19:13:37 GMT -5
I know I had posted some remarks earlier in the year about RB's speed compared to Liberty BASIC, but stumbling upon another great example, I felt compelled to mention it again.
Carl has quite an engine under the hood of this thing. Below is a program written by a gentleman named Henry. I found this on the Just BASIC forum. I left all the remarks in so Henry can get proper credit for his program. The only change I made was to have the "." print after the number 3 (which does slow the program down a bit).
Anyway, running this in LB and selecting 300 digits, my PC took 210.359 seconds to complete.
Running it in RB and selecting 300 digits took 0.236999988 seconds to complete. Wow! That's fast ;D
That's an unbelievable difference! If this same engine is going to be in LB5, no wonder everyone is anxious for it to arrive.
Great job on this Carl!
BASIC dialects are sometimes looked down upon because of speed, but this thing is definitely a race car in the world of BASIC's.
John "Psycho" Siejkowski
Carl has quite an engine under the hood of this thing. Below is a program written by a gentleman named Henry. I found this on the Just BASIC forum. I left all the remarks in so Henry can get proper credit for his program. The only change I made was to have the "." print after the number 3 (which does slow the program down a bit).
Anyway, running this in LB and selecting 300 digits, my PC took 210.359 seconds to complete.
Running it in RB and selecting 300 digits took 0.236999988 seconds to complete. Wow! That's fast ;D
That's an unbelievable difference! If this same engine is going to be in LB5, no wonder everyone is anxious for it to arrive.
Great job on this Carl!
BASIC dialects are sometimes looked down upon because of speed, but this thing is definitely a race car in the world of BASIC's.
John "Psycho" Siejkowski
' pi.bas
' written in Just BASIC by Henry
' a small routine to print pi, the ratio of a circle's
' circumference to its diameter, to as many places as you wish.
' It'll crank out the first 100 digits in a few seconds.
' After a minute it is upto about 200 digits, and reaches
' 300 digits after about 4 minutes but it can go much much
' longer. I've let it run for an hour without crashing
' and it was still churning out digits. :-)
' It's output has been compared to John Fisher's pi program
' and they are the same to 1500 digits. John's, much faster,
' trigonometry program can be found at his website:
' <http://atschool.eduweb.co.uk/taunton/LB/indexlb.html>
' As mentioned above, this program does slow down.
' To see why, change the outer while loop to digits<50,
' then print a, a1, b, b1 or better yet, print their
' sizes. Each one will be more than a googul (10^100).
' The longer you let it run, the larger they get.
' After printing 300 digits a, b, a1, b1 are over
' 1000 digits long. That's insane.
' JB's ability to handle such enormous integers is truly remarkable!
print "This program will compute pi to as many digits as you want."
print "100 digits takes less than 10 seconds. 200 digits takes about a minute."
print "300 digits takes about 4 minutes, etc."
print "You can chose to save the file but either way the number will be displayed on screen."
input "How many digits would you like to compute? ";desiredprecision
print:print
if desiredprecision=0 then desiredprecision=100
t0 = time$("ms")
k = 2 : a = 4 : b = 1 : a1 = 12 : b1 = 4
digits = 0
'desiredprecision = 100
while digits<desiredprecision
' Next approximation
p = k*k
q = 2*k+1
k = k+1
olda1 = a1 : oldb1 = b1
a1 = p*a+q*a1 : b1 = p*b+q*b1
a = olda1 : b = oldb1
' Print common digits
d = int(a / b)
d1 = int(a1 / b1)
while d = d1
if digits>0 then
print d;
else
print d;".";
end if
digits = digits + 1
if digits mod 50=0 then print
a = 10*(a mod b) : a1 = 10*(a1 mod b1)
d = int(a/b) : d1 = int(a1/b1)
wend
wend
t1 = time$("ms")
print "Elapsed time was "; (t1-t0)/1000; " seconds."
End