{"id":31729855,"url":"https://github.com/ron4fun/intxlib4cpp","last_synced_at":"2025-10-09T07:18:12.801Z","repository":{"id":144160183,"uuid":"102853793","full_name":"ron4fun/IntXLib4CPP","owner":"ron4fun","description":"IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation.","archived":false,"fork":false,"pushed_at":"2019-09-13T21:35:08.000Z","size":150,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-23T05:36:01.548Z","etag":null,"topics":["absolute-v","bezout-algorithm","biginteger","cplusplus","cpp","factorial","gcd","intx","lcm","ln","log10","logn","math","miller-rabin","modpower","modular-exponentiation","modular-inverse","pcg","prime-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","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ron4fun.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}},"created_at":"2017-09-08T11:20:32.000Z","updated_at":"2024-03-31T21:36:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1ae4a8c-19c1-4488-8779-13a854daf88d","html_url":"https://github.com/ron4fun/IntXLib4CPP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ron4fun/IntXLib4CPP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FIntXLib4CPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FIntXLib4CPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FIntXLib4CPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FIntXLib4CPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ron4fun","download_url":"https://codeload.github.com/ron4fun/IntXLib4CPP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FIntXLib4CPP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000985,"owners_count":26082972,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["absolute-v","bezout-algorithm","biginteger","cplusplus","cpp","factorial","gcd","intx","lcm","ln","log10","logn","math","miller-rabin","modpower","modular-exponentiation","modular-inverse","pcg","prime-numbers"],"created_at":"2025-10-09T07:18:11.622Z","updated_at":"2025-10-09T07:18:12.794Z","avatar_url":"https://github.com/ron4fun.png","language":"C++","readme":"IntX\n====\n\n **`IntX`** is a C++11 port of [IntX](https://github.com/devoyster/IntXLib) arbitrary precision Integer library with speed, about **`O(N * log N)`** multiplication/division algorithms implementation. It provides all the basic arithmetic operations on Integers, comparing, bitwise shifting etc. It also allows parsing numbers in different bases and converting them to string, also in any base. The advantage of this library is its fast multiplication, division and from base/to base conversion algorithms. all the fast versions of the algorithms are based on fast multiplication of big Integers using [Fast Hartley Transform](http://en.wikipedia.org/wiki/Discrete_Hartley_transform) which runs for **`O(N * log N * log log N)`** time instead of classic **`O(N^2)`**.\n  \n\nCode Example\n------------\n\nHere is a sample of code which uses `IntX` to calculate 42 in power 1048576 (which is 2^20 (1 shl 20)):\n    \n```c++\n#include \u003ciostream\u003e\n#include \u003cWindows.h\u003e\n#include \"Settings\\IntXGlobalSettings.h\"\n#include \"IntX.h\"\n\nvoid Calc()\n{\n\tuint32_t valA, valB;\n\tdouble Delta;\n\n\tvalA = GetTickCount();\n\tIntX::Pow(42, 1048576);\n\tvalB = GetTickCount();\n\tDelta = (valB - valA) / 1000;\n\n\tcout \u003c\u003c Delta \u003c\u003c endl;\n}\n\nint main()\n{\n\tCalc();\n\n\tsystem(\"PAUSE\");\n\n\tTIntX::getGlobalSettings()-\u003esetMultiplyMode(MultiplyMode::mmClassic);\n\n\tCalc();\n\n    return 0;\n} // end main\n```\n\n    First 'Calc()' call uses fast multiplication implementation (which is default), \n    second, classic one. On my machine (Windows 10, Intel Core i5 2.20 GHz, \n    8 GB RAM), Compiled with 64 bits, first call took 0 seconds while the second one \n    took 13 seconds.Resulting number has 1,702,101 digits.\n\n**Some other functions implemented internally by me are**\n\n  \n      IntegerSquareRoot (Integer SquareRoot) \n      Square \n      GCD (Greatest Common Divisor (HCF)) \n      LCM (Least Common Multiple)\n      AbsoluteValue (Get Absolute Value of a Negative TIntX)\n      Bézouts Identity\n      InvMod (Modular Inverse)\n      Factorial\n      IntegerLogN (base, number) (Gets IntegerLog of a number using a specified base)\n\t  Ln (The natural logarithm)\n\t  Log10 (The base-10 logarithm)\n\t  LogN (Logarithm of a number for a specified base)\n      Random (Now Uses PcgRandom Instead of Mersemme Twister)\n      Modular Exponentiation (ModPow)\n      IsProbablyPrime (based on Miller Rabin Primality Test)\n\nAs you can see, `IntX` implements all the standard arithmetic operators using `operator overloading` so its usage is transparent for developers, like if you're working with usual Integers.\n\nFHT and Calculations Precision\n------------------------------\n\nInternally `IntX` library operates with floating-point numbers when multiplication using FHT (Fast Hartley Transform) is performed so at some point it stops working correctly and loses precision. Luckily, this unpleasant side-effects effects starts to appear when Integer size is about 2^28 bytes i.e. for really huge Integers. Anyway, to catch such errors some code was added, FHT multiplication result validity check into code -- it takes N last digits of each big Integer, multiplies them using classic approach and then compares last N digits of classic result with last N digits of FHT result (so it's kind of  a simplified CRC check). If any inconsistency is found, then an \n`FhtMultiplicationException` is thrown; this check can be disabled using global settings.\n\nInternal Representation and ToString() Performance\n--------------------------------------------------\n\n   For a really huge Integer numbers (like 42 in power 1048576 above) `ToString()` \n call can take quite some time to execute. This is because, internally `IntX` big \n Integers are stored as `2^32`-base number in `UInt32` array and to generate decimal \n string output it should be converted from `2^32` base to decimal base. Such digits \n storage approach was chosen intentionally -- it makes `ToString()` slower but uses \n memory efficiently and makes primitive operations on digits faster than power of \n 10-base storage (which would make `ToString()` work faster) and \n usually computations are used more often than `ToString()`.\n\n**Tested Enviroments:**\n     \n    Visual Studio 2015.\n\n\n###License\n\nThis \"Software\" is Licensed Under  **`MIT License (MIT)`** .\n    \n\nConclusion\n--------------------------------------------------\n\n    Special Thanks to first of all, (Andriy Kozachuk) for creating the Original CSharp\n\tversion and Xor-el for various support offered.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fron4fun%2Fintxlib4cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fron4fun%2Fintxlib4cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fron4fun%2Fintxlib4cpp/lists"}