{"id":19447558,"url":"https://github.com/mrfibunacci/approximate-pi","last_synced_at":"2026-06-12T06:02:45.351Z","repository":{"id":182855655,"uuid":"127475066","full_name":"MrFibunacci/approximate-pi","owner":"MrFibunacci","description":"A simple approximation of the circle constant pi using a \"monte carlo\" method. Its not the most efficient or most elegant way to do it but is does something. Right now its just returning the difference of the calculated value and pi.","archived":false,"fork":false,"pushed_at":"2018-10-06T19:14:02.000Z","size":12,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-25T08:48:09.653Z","etag":null,"topics":["approximation","math","pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrFibunacci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-30T21:34:14.000Z","updated_at":"2019-08-11T19:09:18.000Z","dependencies_parsed_at":"2023-07-21T22:00:19.864Z","dependency_job_id":null,"html_url":"https://github.com/MrFibunacci/approximate-pi","commit_stats":null,"previous_names":["mrfibunacci/approximate-pi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MrFibunacci/approximate-pi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrFibunacci%2Fapproximate-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrFibunacci%2Fapproximate-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrFibunacci%2Fapproximate-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrFibunacci%2Fapproximate-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrFibunacci","download_url":"https://codeload.github.com/MrFibunacci/approximate-pi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrFibunacci%2Fapproximate-pi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34231212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["approximation","math","pi"],"created_at":"2024-11-10T16:18:35.279Z","updated_at":"2026-06-12T06:02:45.332Z","avatar_url":"https://github.com/MrFibunacci.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# approximate-pi\n\nA simple approximation of the circle constant pi using the \"[monte carlo](https://en.wikipedia.org/wiki/Monte_Carlo_algorithm)\" method.\n\n# monte calo algorithm\nMy implementaion is simple I use an modified verion of `rand()`,just that I get an double within an range, to drop my points.\nMy calculation in `approximatePI()` is:\n\n`(pointsInCircle * pointsTotal) / 4`\n\n## how it works\n\nIt's simple we throw dots on an imaginary square with an cirlce in it (with `a = r^2`) and count how many dots are in the circle and how many we have in total. Than we do the calculation from above.\n\nThe determination rater the dot is in the circle or not is done by using Pythagoras rule a^2 + b^2 = c^2 to calculate the distance between the centre and the point.\nIf the result is greater than the radius its not in the circle.\n\n# not my stuff:\n\nThe `fRand()` function is from stackoverflow user [Frank](https://stackoverflow.com/users/60628/frank) posted in https://stackoverflow.com/questions/2704521/generate-random-double-numbers-in-c\n\nI use the [BigFloat](https://github.com/Mariotti94/BigFloat) - Arbitrary-Precision Float Arithmetic Library by [Gianfranco Mariotti](https://github.com/Mariotti94)\n\n# idea\n\nI got the idea to do an c++ implementation of an aproximation of pi because of an [video](https://www.youtube.com/watch?v=5cNnf_7e92Q) by [CodingTrain](https://github.com/CodingTrain).\nI wrote some of the code simular to the one in video, so that is also not quite my stuff.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrfibunacci%2Fapproximate-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrfibunacci%2Fapproximate-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrfibunacci%2Fapproximate-pi/lists"}