{"id":15047476,"url":"https://github.com/atmofx/bigint","last_synced_at":"2026-03-13T14:33:22.657Z","repository":{"id":212930499,"uuid":"732619445","full_name":"AtmoFX/bigint","owner":"AtmoFX","description":"C++ big integer library","archived":false,"fork":false,"pushed_at":"2025-01-30T10:40:58.000Z","size":906,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:50:55.452Z","etag":null,"topics":["bigint","biginteger","biginteger-library","competitive-programming","cpp","cpp-library","cpp11","cpp14","cpp17","cpp20","cpp23","scientific-calculations","scientific-computing"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AtmoFX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","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}},"created_at":"2023-12-17T09:42:41.000Z","updated_at":"2025-01-30T10:41:01.000Z","dependencies_parsed_at":"2024-02-07T07:27:51.717Z","dependency_job_id":"46315959-6fd3-448e-a517-5211d463bd42","html_url":"https://github.com/AtmoFX/bigint","commit_stats":{"total_commits":111,"total_committers":1,"mean_commits":111.0,"dds":0.0,"last_synced_commit":"0fcb0e41cf14cde6e18705ff11b29d269f350550"},"previous_names":["atmofx/bigint"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtmoFX%2Fbigint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtmoFX%2Fbigint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtmoFX%2Fbigint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtmoFX%2Fbigint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtmoFX","download_url":"https://codeload.github.com/AtmoFX/bigint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137999,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bigint","biginteger","biginteger-library","competitive-programming","cpp","cpp-library","cpp11","cpp14","cpp17","cpp20","cpp23","scientific-calculations","scientific-computing"],"created_at":"2024-09-24T20:58:53.834Z","updated_at":"2026-03-13T14:33:22.611Z","avatar_url":"https://github.com/AtmoFX.png","language":null,"readme":"![License](https://img.shields.io/badge/License-MIT-blue)\n![Status](https://img.shields.io/badge/Status-alpha_release-lightgray)\n![Coverage](https://img.shields.io/badge/Coverage-100%25-limegreen)\n![Documentation](https://img.shields.io/badge/Documentation-In_progress-orange)\n\n# bigint\n\nC++ big integers, with explanations.\n\nTo get started, download the [archive](https://github.com/AtmoFX/bigint/blob/master/source/bigint.zip) containing header and source files, include it in your code, and compile however you would.\n\n## A summary of the project\n\n**Do you need thousands of digits? Millions? More? This library got you covered!\u003cbr/\u003e\nAre you after documentation but cannot be bothered looking up for research papers? Browse the resources here.**\n\nThere are already many big integer libraries out there:\n\n- GMP (The GNU Multiple Precision Arithmetic Library) is by far the most well-known, and not only for integers.\nWith more than 30 years since its first release, it has become the reference to achieve the best possible performance.\u003cbr/\u003e\nIt is also a very complex piece of work written in C and Assembler, hard to include in modern C++ projects (especially under Windows) and definitely not the easiest way to get an introduction to the underlying mathematics and algorithms.\n- Other libraries have a different offer: much more simple but for most of them, painfully slow (and finding one of the few fast libraries inside a list that big is a challenge).\u003cbr/\u003e\nAmong the flaws of these \"slow\" libraries, we find:\n   - Poorly written loops / memory management: some functions require only a few minutes of work to run in a fraction of the time.\n   - Lack for the more complex but also more efficient algorithms, including libraries that claim they have implemented these optimizations.\n\n**This project is an attempt at providing a better compromise**:\u003cbr/\u003e\n - Simplicity is the main goal but not at the cost of seeing programs run until the death of the Sun. This is very much a work in progress and a lot is yet to be implemented; based on the history of GMP, it may never end.\n - While we are at it, we aim at providing a more comprehensive documentation for the less sophisticated readers. We hope to make it a good introduction for those who have not dived into research papers yet.\n\n## ToC\n\n1. [Highlights](.#Highlights)\n1. [Usage](.#Usage)\n1. [Documentation](.#Documentation)\n1. [License](.#License) \n\n## Highlights\n\n- Modern C++ (compiles with C++11 / C++14 / C++17 / c++20).\n- Simple operations:  \n  - Artithmetic: `+`, `-`, `*`, `/`, `%`\n  - Comparison: `==`, `!=`, `\u003c=`, `\u003e=`, `\u003c`, `\u003e`\n  - Bitwise operations: `\u003c\u003c`, `\u003e\u003e`\n- Advanced functions such as factorials.\n\nMore to come in the future.\n\n## Usage\n\n## Documentation\n\n### Basics\n\n[Type definition](https://github.com/AtmoFX/bigint/blob/master/documentation/basics.md)\u003cbr/\u003e\nDefined inside the `bigint` namespace, use arbitrarily large integers with the `bigint_t` class.\nBig integers can be created from regular integer types or from any `std::string` representing an integer, then manipulated normally:\n```c++\nusing namespace bigint;\nbigint_t a(123456789), b(987654321),\n          c = a + b, d = c * c;\n\nstd::cout \u003c\u003c d;\n```\n\n### Operators\n\n Arithmetic operations working for regular integers are overloaded to work with big integers. The algorithms behind these operations are aimed to have fast algorithmic complexity. \n Because calculating numbers without any way to output them would make the library rather useless, stream operators render big integers as strings.\n\n[Comparison](https://github.com/AtmoFX/bigint/blob/master/documentation/comparison.md)\u003cbr/\u003e\nBig integers of any size can be compared to one another.\n```c++\nusing namespace bigint;\nbigint_t a(\"123456789123456789123456789123456789\"),\n          b(\"987654321987654321987654321987654321987654321\");\nbool e  = (a == b),  //false\n     ne = (a != b),  //true\n     gt = (a \u003e  b),  //false\n     ge = (a \u003e= b),  //false\n     lt = (a \u003c  b),  //true\n     le = (a \u003c= b);  //true\n//Since C++20\nauto ss = (a \u003c=\u003e b); //std::strong_ordering::less\n```\n\n[Addition / Subtraction](https://github.com/AtmoFX/bigint/blob/master/documentation/addition_subtraction.md)\u003cbr/\u003e\nAdd/subtract big integers normally:\n```c++\nbigint_t x = a + b, y = c - d;\n```\n\nBit-wise operations\u003cbr/\u003e\nIn progress.\n\n[Multiplication](https://github.com/AtmoFX/bigint/blob/master/documentation/multiplication.md)\u003cbr/\u003e\nMultiply big integers normally. Multiplication is a complex operation that deserves its own separate documentation.\n```c++\nbigint_t x = a * b;\n```\n\nDivision / Mod\u003cbr/\u003e\nPerform big integers division normally. The division is more complex and generally slower than even the multiplication, but it tends to be used less often and the results it produces are smaller than its passed operands.\n```c++\nbigint_t x = a / b, y = a % b;\n```\n\nOptimized algorithms and documentation are in progress.\n\nInput/Output of a `bigint_t`\u003cbr/\u003e\nAs the `bigint_t` class is a complex structure, showing their digits in a base other than than a power of 2 requires specialized functions. As for the rest, the library allows for big integers to be manipulated like regular integers.\n```c++\nstd::string s = a.toString();\nstd::cout \u003c\u003c a;\n```\n\nOptimized algorithms and documentation are in progress.\n \n ### Advanced algorithms\n\n The `bigint` namespace is shipped with more complex algorithms, with a non-obvious approach to ensure it outperforms naive implementations.\n\n[Power](https://github.com/AtmoFX/bigint/blob/master/documentation/power.md)\u003cbr/\u003e\nThe power function calculates $n^p = \\overbrace{n \\times n \\times n \\times \\dotsc \\times n}^{p\\text{ times}}$.\u003cbr/\u003e\nThis is done with $\\text{O}(\\text{log}(p))$ multiplications.\n```c++\nauto np bigint::power(123456789ULL, 62125); // 123456789 ^ 62125 \n```\n\n[Factorials](https://github.com/AtmoFX/bigint/blob/master/documentation/factorial.md)\u003cbr/\u003e\nThe factorial function calculates $n! = 1 \\times 2 \\times 3 \\times \\dotsc \\times n$ (typed: `size_t`).\u003cbr/\u003e\nThe function uses about half the multiplications that would normally be required for this calculation and does so by pairing operands in a way that better uses the multiplication algorithms, compared to the naive approach.\n```c++\nauto f = bigint::factorial(100000); // 100k!\n```\n\n[Fibonacci sequence + generalization](https://github.com/AtmoFX/bigint/blob/master/documentation/fibonacci.md)\u003cbr/\u003e\nThe Fibonacci sequence is a very famous sequence of integers, supported only up to its 93\u003csup\u003erd\u003c/sup\u003e element when using 64-bit unsigned integers. `bigint::fibonacci` can go way, way beyond that point using an elaborate algorithm to diminish the calculation time as much as possible.\u003cbr/\u003e\nThe algorithm is designed to produce consecutive Fibonacci numbers between 2 indices and handles 2 types of generalization of the Fibonacci sequence:\n  - With custom values as first elements in the series.\u003cbr/\u003e\n  This allows the algorithm to generate Lucas numbers, other Fibonacci-like sequences and to have a stop\u0026resume capability.\n  - With higher order: generate a sequence where each number is the sum of the $k$, instead of only 2, elements preceding it.\n\n```c+\nauto f = bigint::fibonacci(500000);\n```\n\n## License\n\nThis library and its associated documentation are separately provided under [MIT license](https://github.com/AtmoFX/bigint/blob/master/License.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatmofx%2Fbigint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatmofx%2Fbigint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatmofx%2Fbigint/lists"}