{"id":19337443,"url":"https://github.com/stefanuhrig/bignum","last_synced_at":"2026-06-20T14:32:36.804Z","repository":{"id":230412822,"uuid":"779306879","full_name":"stefanuhrig/bignum","owner":"stefanuhrig","description":"A C++-11 single-header generic arbitrary-precision number library","archived":false,"fork":false,"pushed_at":"2024-04-11T18:09:45.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T08:15:05.388Z","etag":null,"topics":["arbitrary-precision","bignum","cpp","rational-numbers"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefanuhrig.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}},"created_at":"2024-03-29T14:25:50.000Z","updated_at":"2024-03-29T15:07:46.000Z","dependencies_parsed_at":"2024-04-11T19:31:01.620Z","dependency_job_id":null,"html_url":"https://github.com/stefanuhrig/bignum","commit_stats":null,"previous_names":["stefanuhrig/bignum"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stefanuhrig/bignum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuhrig%2Fbignum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuhrig%2Fbignum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuhrig%2Fbignum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuhrig%2Fbignum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanuhrig","download_url":"https://codeload.github.com/stefanuhrig/bignum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuhrig%2Fbignum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34573729,"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-20T02:00:06.407Z","response_time":98,"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":["arbitrary-precision","bignum","cpp","rational-numbers"],"created_at":"2024-11-10T03:14:23.286Z","updated_at":"2026-06-20T14:32:36.780Z","avatar_url":"https://github.com/stefanuhrig.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A C++-11 single-header generic arbitrary-precision number library\n\n[![codecov](https://codecov.io/github/stefanuhrig/bignum/graph/badge.svg?token=LKHJZ14LTD)](https://codecov.io/github/stefanuhrig/bignum)\n\n## About\n\nThis is a C++-11 compliant generic single-header arbitrary-precision \nnumber library offering natural ($\\mathbb{N}$), integer ($\\mathbb{Z}$) and \nrational ($\\mathbb{R}$) number types and corresponding mathematical operations.\n \nDesign goals of this library are\n - intuitive and easy usage\n - providing all functionality in a single header so that it can easily be\n   consumed by C++ projects\n - maximum compatibility with C++-11 compliant compilers and all platforms\n\nThis library does not contain optimized algorithms for any particular platform \nand uses mainly naive \"schoolbook\" methods. With regards to performance, it \ncannot compete with mature arbitrary-precision libraries like GMP.\n\nThe given time complexity is the worst case complexity. $n$ is the number of \ndigits in a number. If multiple numbers are involved in an operation, $n$ is \nchosen to be the number of digits in the longest number.\n\nIf you'd like to improve the performance on a particular architecture, you can \ncustomize the digit type and the seven primitive operations on which all \nalgorithms are based.\n\n## Usage\n\nTo use the library, you can just copy [bignum.h](include/bignum.h) to your\nproject.\n\n## Example\n\nParticular useful is the capability to convert double-precision floating-point \nnumbers to rational numbers and to round rational numbers to the nearest \ndouble-precision floating-point number. This might be used to find the correctly\nrounded double-precision floating-point value of transcedental functions. The \nfollowing code (optimized for readability) demonstrates how the sine of a double\ncan be computed using the Taylor series:\n\n$$\\sin(x) = x - \\frac{1}{3!}x^3 + \\frac{1}{5!}x^5 - \\frac{1}{7!}x^7 ...$$\n\n```c++\n#include \"bignum.h\"\n\nusing namespace bn;\nusing namespace std;\n\ndouble crsin(double arg)\n{\n    Rational x = arg;\n    Rational prev_acc;\n    Rational curr_acc = x;\n    Rational term = x;\n    Unsigned factorial = 1;\n    Signed sign = 1;\n    do {\n        prev_acc = std::move(curr_acc);\n        sign *= -1;\n        term *= x * x;\n        term /= (factorial + 1) * (factorial + 2);\n        factorial += 2;\n        curr_acc = prev_acc + sign * term;\n    } while (static_cast\u003cdouble\u003e(curr_acc) != static_cast\u003cdouble\u003e(prev_acc));\n    return static_cast\u003cdouble\u003e(curr_acc);\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanuhrig%2Fbignum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanuhrig%2Fbignum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanuhrig%2Fbignum/lists"}