{"id":31959918,"url":"https://github.com/stepainpy/fwnbi","last_synced_at":"2026-07-11T21:32:01.447Z","repository":{"id":318008446,"uuid":"1067424921","full_name":"Stepainpy/fwnbi","owner":"Stepainpy","description":"Fixed-width N-bit integers","archived":false,"fork":false,"pushed_at":"2025-11-27T21:00:39.000Z","size":271,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-30T11:56:13.631Z","etag":null,"topics":["arbitrary-precision-integers","constexpr","cpp","cpp11","fixed-width","integer","integer-arithmetic","integers","karatsuba-multiplication","std"],"latest_commit_sha":null,"homepage":"https://stepainpy.github.io/fwnbi/","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/Stepainpy.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-30T20:57:30.000Z","updated_at":"2025-11-13T20:38:40.000Z","dependencies_parsed_at":"2025-10-04T14:31:30.314Z","dependency_job_id":"17756e1e-7843-4c0e-b136-7e2bdb6fe221","html_url":"https://github.com/Stepainpy/fwnbi","commit_stats":null,"previous_names":["stepainpy/fwnbi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Stepainpy/fwnbi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Ffwnbi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Ffwnbi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Ffwnbi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Ffwnbi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stepainpy","download_url":"https://codeload.github.com/Stepainpy/fwnbi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Ffwnbi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35376133,"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-07-11T02:00:05.354Z","response_time":104,"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-integers","constexpr","cpp","cpp11","fixed-width","integer","integer-arithmetic","integers","karatsuba-multiplication","std"],"created_at":"2025-10-14T15:51:11.299Z","updated_at":"2026-07-11T21:32:01.441Z","avatar_url":"https://github.com/Stepainpy.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fixed-width N-bit integers\r\n\r\n## Overview\r\n\r\nImplement template class `fwnbi::basic_integer\u003csize_t Bits, class DigitT, bool Signed\u003e`\r\nwith semantic as fundamental integer types.\r\n\r\nValid values of `Bits`: $\\text{Bits} \u003e 0$ and\r\n$\\text{Bits} \\equiv 0 \\pmod{\\text{bits in DigitT}}$.  \r\nValid values of `DigitT`: `fwnbi::digit::u(8/16/32)`\r\n(and `fwnbi::digit::u64` if available type `__uint128_t`, GCC extension).\r\n\r\nFor multiplication use, the Karatsuba algorithm.\r\n\r\nAvailable `constexpr` function since C++14.\r\n\r\n## Namespace `fwnbi`\r\n\r\n### Class `basic_integer\u003csize_t Bits, class DigitT, bool Signed\u003e`\r\n\r\n**Types:**  \r\n`digit_type` - equal template parameter `DigitT`  \r\n`double_digit_type` - type with width twice as wide as `digit_type`  \r\n`reference` - equal `digit_type\u0026`  \r\n`const_reference` - equal `const digit_type\u0026`  \r\n`pointer` - equal `digit_type*`  \r\n`const_pointer` - equal `const digit_type*`  \r\n`iterator` - equal `digit_type*`  \r\n`const_iterator` - equal `const digit_type*`\r\n\r\n**Static constants:**  \r\n`bit_width` - equal template parameter `Bits`  \r\n`digit_width` - bit width of `digit_type`  \r\n`digit_count` - count of digits in `basic_integer\u003c...\u003e`  \r\n`is_signed` - equal template parameter `Signed`\r\n\r\n**Static functions:**  \r\n`max()` - return max value for current `basic_integer\u003c...\u003e`  \r\n`min()` - return min value for current `basic_integer\u003c...\u003e`\r\n\r\n**Constructors:**  \r\n`basic_integer()` - default constructor (set all zero)  \r\n`basic_integer(digit_type)` - create integer from one digit  \r\n`basic_integer(double_digit_type)` - create integer from \"two\" digit  \r\n`basic_integer(const digit_type (\u0026)[digit_count])` - create integer from array of digits  \r\n`basic_integer(const std::array\u003cdigit_type, digit_count\u003e\u0026)` - create integer from std::array of digits\r\n\r\n**Conversions:**  \r\n`bool` - `false` if integer is zero, otherwise `true`  \r\n`digit_type` - return first digit  \r\n`double_digit_type` - return first and second digit  \r\n`basic_integer\u003c!Signed, ...\u003e` - toggle sign of integer  \r\n`basic_integer\u003cBgBits, ...\u003e` - expand bit width, $\\text{BgBits} \u003e \\text{Bits}$  \r\n`basic_integer\u003cTnBits, ...\u003e` - narrow bit width, $\\text{TnBits} \u003c \\text{Bits}$  \r\n`basic_integer\u003cOtherDigitT, ...\u003e` - change digit type, $\\text{OtherDigitT} \\ne \\text{DigitT}$\r\n\r\n**Comparison:**  \r\n`int compare(const basic_integer\u003c...\u003e\u0026)` - 3-way comparison  \r\n`std::strong_ordering operator\u003c=\u003e(const basic_integer\u003c...\u003e\u0026)` *since C++20* - standard 3-way comparison\r\n\r\n**Support methods:**  \r\n`bool sign_bit()` - return value of MSB  \r\n`int sign()` - n \u003e 0 =\u003e +1, n = 0 =\u003e 0, n \u003c 0 =\u003e -1  \r\n`size_t width()` - return actual bit width of current value  \r\n`void clear()` - set all digits in zero  \r\n`bool bit(size_t)` - return value of bit by index, $0 \\le \\text{index} \u003c \\text{Bits}$  \r\n`void bit(size_t, bool)` - set bit by index, $0 \\le \\text{index} \u003c \\text{Bits}$  \r\n`uint8_t hex(size_t)` - return value of hex digit by index, $0 \\le \\text{index} \u003c \\frac{\\text{Bits}}{4}$  \r\n`void hex(size_t, uint8_t)` - set hex digit by index, $0 \\le \\text{index} \u003c \\frac{\\text{Bits}}{4}$  \r\n`void split(basic_integer\u003cBitsU, ...\u003e\u0026, basic_integer\u003cBitsL, ...\u003e\u0026)` - split current integer by upper and lower parts  \r\n`void merge(const basic_integer\u003cBitsU, ...\u003e\u0026, const basic_integer\u003cBitsL, ...\u003e\u0026)` - merge upper and lower parts to current integer  \r\n`basic_integer\u003cBgBits, ...\u003e expand()` - expand bit width without copy sign bit, $\\text{BgBits} \u003e \\text{Bits}$  \r\n`bool add_with_carry(const basic_integer\u003c...\u003e\u0026, bool = false)` - add first and second argument to integer and return carry  \r\n`bool add_with_carry(digit_type, bool = false)` - add first and second argument to integer and return carry  \r\n`void swap(basic_integer\u003c...\u003e\u0026)` - swap value of current integer and argument\r\n\r\n**Range methods:**  \r\n`[const_]pointer data() [const]` - return [const] pointer to begin of digit array  \r\n`[const_]iterator begin() [const]` - return begin [const] iterator for digits  \r\n`const_iterator cbegin() const` - return begin const iterator for digits  \r\n`[const_]iterator end() [const]` - return end [const] iterator for digits  \r\n`const_iterator cend() const` - return end const iterator for digits\r\n\r\n**Additional operators:**  \r\n`[const_]reference operator[](size_t) [const]` - return [const] reference to digit by index  \r\n`\u003c\u003c`, `\u003e\u003e`, `\u003c\u003c=`, `\u003e\u003e=` - if count is negative turn left/right to right/left\r\n\r\n### Functions\r\n\r\n`fullmul` - return 2N-bit result of multiplication N-bit integers  \r\n`abs` - return absolute value of integer  \r\n`rotl`/`rotr` - bit rotation, if count is negative turn left/right to right/left  \r\n`clz` - return count `0`-bit from MSB to before first `1`-bit  \r\n`ctz` - return count `0`-bit from LSB to before first `1`-bit  \r\n`popcount` - return count of `1`-bit in integer  \r\n`byteswap` - swap byte order in integer (`1234` \u003c=\u003e `4321`)  \r\n`modpow` - modular exponentiation function  \r\n`sqr` - return square of integer with twice width  \r\n`isqrt` - return `floor(sqrt(x))` of integer  \r\n`gcd` - return greate common divisor  \r\n`lcm` - return least common multiplier\r\n\r\n### Default provided type aliases\r\n\r\n`[u]intN_t\u003cBits, DigitT = /* BIGGEST DIGIT */\u003e` - aliases with preset signedness  \r\n`uint(128/256/512/1024)_t` - unsigned aliases  \r\n`int(128/256/512/1024)_t` - signed aliases\r\n\r\n`/* BIGGEST DIGIT */` - biggest digit type for `Bits`\r\n\r\n## Namespace `fwnbi::digit`\r\n\r\n`u8`/`u16`/`u32`/`u64` - digit types\r\n\r\n## Namespace `fwnbi::literals`\r\n\r\n`_ull(128/256/512/1024)` - unsigned  \r\n`_ll(128/256/512/1024)` - signed  \r\n`_ull(128/256/512/1024)d8` - unsigned with digit type `u8`  \r\n`_ll(128/256/512/1024)d8` - signed with digit type `u8`\r\n\r\n## Namespace `std`\r\n\r\n`void swap(...)` - swapping to integers  \r\n`struct numeric_limits` - information about `basic_integer\u003c...\u003e`  \r\n`struct is_integral` - return `true`  \r\n`struct is_unsigned`/`struct is_signed` - answer by question  \r\n`struct make_unsigned`/`struct make_signed` - return type  \r\n`struct hash` - calculate function FNVa-64 for bytes in integer  \r\n`std::string to_string(...)` - convert integer to `std::string`  \r\n`... strtoll\u003c...\u003e(...)` - convert C-string to signed integer  \r\n`... strtoull\u003c...\u003e(...)` - convert C-string to unsigned integer  \r\n`... operator\u003c\u003c(...)` - output to `std::basic_ostream\u003c...\u003e`  \r\n`... operator\u003e\u003e(...)` - input from `std::basic_istream\u003c...\u003e`  \r\n`... to_chars(...)` *since C++17* - fast convert to string  \r\n`... from_chars(...)` *since C++17* - fast convert from string  \r\n`struct formatter\u003c...\u003e` *since C++20* - helper class for format library","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepainpy%2Ffwnbi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepainpy%2Ffwnbi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepainpy%2Ffwnbi/lists"}