|
Post by Stefan Pendl on Apr 24, 2022 2:46:02 GMT -5
Running the code below in LB4 one can close the window during execution of the program, where LB5 is not reacting at all. Commenting the SCAN command out in LB4 will result in the same behavior as LB5.
'calculate pi.bas 'Author: Stefan Pendl 'Date: 21.04.22
n=-1 p=0 npi=0 pi = Asn(1) * 2 count=0 difference=1/10 row=2 startTime=time$("ms")
while difference>0.000001 do n=n+2
if p=0 then npi=npi+4/n else npi=npi-4/n end if
locate 1,row print npi
p=not(p) scan count=count+1 loop until abs(pi - npi) < difference endTime=time$("ms") elapsedTime=endTime-startTime
if elapsedTime > (60*60*1000) then elapsedHours=int(elapsedTime/1000/60/60) elapsedTime=elapsedTime-(elapsedHours*1000*60*60) end if if elapsedTime > (60*1000) then elapsedMinutes=int(elapsedTime/1000/60) elapsedTime=elapsedTime-(elapsedMinutes*1000*60) end if if elapsedTime > 1000 then elapsedSeconds=int(elapsedTime/1000) elapsedTime=elapsedTime-(elapsedSeconds*1000) end if
print count; " calculations needed to calculate pi" print " to a difference of "; difference; " from "; pi print " calculation took ";elapsedHours;":";right$("0";elapsedMinutes,2);":";right$("0";elapsedSeconds,2);".";right$("00";elapsedTime,3)
difference=difference/10 row=row+5 wend end Thanks in advance for fixing.
|
|