6502 nut; awk fan; avid reader if not for so much time online; once a chip designer; fan of one-line programs & ingenuity generally. Amateur interest in prime numbers and pi
#retrocomputing #computerhistory
Posts
RE: @th@social.v.st
> No wonder the ship tipped to the port side when the winds hit. But why was the ship so lopsided? While examining the ship, Hocker discovered four rulers the workmen had used. Those rulers were based on different standards of measurement at the time. Two were in Swedish feet, which were divided into twelve inches. The other two were in Amsterdam feet, which had eleven inches in a foot. So each carpenter had used his own system of measurement.
For what it's worth (very little!) here's that 8.11 second version in (very) BBC Basic:
0 T%=TIME
1 N%=20: L%=10*N%/3: DIM A%(255): Z$="000000":T$="999999"
2 FORI%=1TOL%:A%(I%)=2:NEXT: M%=0:P%=0:FORJ%=1TON%:Q%=0:K%=2*L%+1
3 FORI%=L%TO1STEP-1:K%=K%-2:X%=A%(I%)*&A+I%*Q%:Q%=X%DIVK%:A%(I%)=X%-K%*Q%:NEXT:Y%=Q%DIV&A:A%(1)=Q%-Y%*&A:Q%=Y%:IFQ%<9PRINT;P%LEFT$(T$,M%);:P%=Q%:M%=0:NEXTELSEIFQ%=9M%=M%+1:NEXTELSEPRINT;P%+1LEFT$(Z$,M%);:P%=0:M%=0:NEXT
4 PRINT;P%:PRINT (TIME-T%)/100;" seconds"
Run in browser here: https://bbcmic.ro/#%7B%22v%22%3A1%2C%22program%22%3A%220%20T%25%3DTIME%5Cn1%20N%25%3D20%3A%20L%25%3D10N%25%2F3%3A%20DIM%20A%25%28255%29%3A%20Z%24%3D%5C%22000000%5C%22%3AT%24%3D%5C%22999999%5C%22%5Cn2%20FORI%25%3D1TOL%25%3AA%25%28I%25%29%3D2%3ANEXT%3A%20M%25%3D0%3AP%25%3D0%3AFORJ%25%3D1TON%25%3AQ%25%3D0%3AK%25%3D2L%25%2B1%5Cn3%20FORI%25%3DL%25TO1STEP-1%3AK%25%3DK%25-2%3AX%25%3DA%25%28I%25%29*%26A%2BI%25Q%25%3AQ%25%3DX%25DIVK%25%3AA%25%28I%25%29%3DX%25-K%25Q%25%3ANEXT%3AY%25%3DQ%25DIV%26A%3AA%25%281%29%3DQ%25-Y%25*%26A%3AQ%25%3DY%25%3AIFQ%25%3C9PRINT%3BP%25LEFT%24%28T%24%2CM%25%29%3B%3AP%25%3DQ%25%3AM%25%3D0%3ANEXTELSEIFQ%25%3D9M%25%3DM%25%2B1%3ANEXTELSEPRINT%3BP%25%2B1LEFT%24%28Z%24%2CM%25%29%3B%3AP%25%3D0%3AM%25%3D0%3ANEXT%5Cn4%20PRINT%3BP%25%3APRINT%20%28TIME-T%25%29%2F100%3B%5C%22%20seconds%5C%22%22%7D
RE: @electron_greg@oldbytes.space
A nice Pi benchmark in a more or less universal Basic. As noted downthread, this isn't an invitation to compare methods, but a fixed method to compare platforms.
But of course the temptation is very strong! The BBC Micro runs this version in 19 seconds - with some considerable noodling I got it down to 8.11 seconds, but it's now very BBC Basic specific.
And of course, we can do better by tweaking the algorithm - base 10000 is a lot faster than base 10, and just as useful.
A program very like the one exhibited here, and credited to Valentin Albillo, appears in the Stardot thread "Calculating digits of Pi in Basic"
https://stardot.org.uk/forums/viewtopic.php?t=18066
The best BBC Basic effort I could come up with is towards the end of that thread, producing the requested 20 digits in 2.07 seconds.