{"id":17140936,"url":"https://github.com/biged/pi-spigot-for-micros","last_synced_at":"2026-01-29T15:33:31.177Z","repository":{"id":239305294,"uuid":"799151169","full_name":"BigEd/pi-spigot-for-micros","owner":"BigEd","description":"Calculating pi digit by digit on 1980s micros","archived":false,"fork":false,"pushed_at":"2024-09-09T13:38:55.000Z","size":239,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T10:13:13.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BigEd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-11T10:07:40.000Z","updated_at":"2024-11-28T13:26:43.000Z","dependencies_parsed_at":"2024-08-01T17:22:48.468Z","dependency_job_id":"dc837d2c-e350-41a8-a841-19896ce622e5","html_url":"https://github.com/BigEd/pi-spigot-for-micros","commit_stats":null,"previous_names":["biged/pi-spigot-for-micros"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BigEd/pi-spigot-for-micros","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigEd%2Fpi-spigot-for-micros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigEd%2Fpi-spigot-for-micros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigEd%2Fpi-spigot-for-micros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigEd%2Fpi-spigot-for-micros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BigEd","download_url":"https://codeload.github.com/BigEd/pi-spigot-for-micros/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BigEd%2Fpi-spigot-for-micros/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28880237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T20:23:48.576Z","updated_at":"2026-01-29T15:33:31.161Z","avatar_url":"https://github.com/BigEd.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pi-spigot-for-micros\nCalculating pi digit by digit on 1980s micros - a work in progress (see the discussion thread [here](https://www.stardot.org.uk/forums/viewtopic.php?t=29301).)\n\nWe hope to benchmark against previous work by litwr which uses Rabinowitz' spigot:\n- http://litwr2.atspace.eu/pi/pi-spigot-benchmark.html\n- https://stardot.org.uk/forums/viewtopic.php?t=11458\n- https://github.com/litwr2/rosetta-pi-spigot\n\nWe're using the BBP formula for pi calculation, adjusted to produce decimal digits, following the relay computer work presented by The Science Elf\n- https://youtu.be/SPTzzSuBFlc\n\nWhen we've done that, we plan to implement Bellard's improved approach which promises to run faster but should be able to reuse the same machinery\n- https://bellard.org/pi/\n\nThe algorithm can be written simply in BBC Basic like this\n```\nREM BBP - see github.com/BigEd/pi-spigot-for-micros\nREM 10 digits correct with BBC Basic on 6502\nREM 19 digits correct with BBC Basic on x86\nS=0:N=1\nFOR K=0 TO 8*20 STEP 8\n  S=S+4*N/(K+1)\n  S=S-2*N/(K+4)\n  S=S-N/(K+5)\n  S=S-N/(K+6)\n  PRINT \"digit \";INT(S)\n  S=S-INT(S)\n  S=S*10\n  N=N*10/16\nNEXT\n```\nbut to get more than a few digits we will need bignum operations: N and S both need high precision. However, neither of them become very large or very small so fixed point will be fine.  We need to multiply a bignum by a small number, to add and subtract bignums, to scale a bignum by a fraction, and to divide a bignum by a small number.\n\nTo take a simple approach we will need one or more temporary bignums which will cost both time and space.  We expect to be able to refine our approach to use only two bignums, and possibly even to share space as one grows while the other one shrinks.\n\nThe Bellard algorithm is also simple to capture in BBC Basic:\n```text\nREM Bellard - github.com/BigEd/pi-spigot-for-micros\nREM 11 digits correct with BBC Basic on 6502\nREM 19 digits correct with BBC Basic on x86\nF=0:T=0:S=0:N=1/64\nFOR K=0 TO 4\n  S=S+256*N/(T+1)\n  S=S-64*N/(T+3)\n  S=S-4*N/(T+5)\n  S=S-4*N/(T+7)\n  S=S+1*N/(T+9)\n  S=S-32*N/(F+1)\n  S=S-1*N/(F+3)\n  PRINT ;\" \"INT(S);\n  S=S-INT(S)\n  S=S*1000\n  N=-N*250/256\n  F=F+4:T=T+10\nNEXT\nPRINT\n```\nNotice in both cases that most constants are powers of two which should help.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiged%2Fpi-spigot-for-micros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiged%2Fpi-spigot-for-micros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiged%2Fpi-spigot-for-micros/lists"}