Slides for P3639R0 — The _BitInt Debate
- Document number:
- P3721R0
- Date:
2025-06-04 - Audience:
- SG22
- Project:
- ISO/IEC 14882 Programming Languages — C++, ISO/IEC JTC1/SC22/WG21
- Reply-To:
- Jan Schultke <janschultke@gmail.com>
- Source:
- github.com/Eisenwave/cpp-proposals/blob/master/src/bitint-debate-slides.cow
- →, ↓ : go to the next slide
- ←, ↑ : go to previous slide
The _BitInt Debate
P3639R0
Introduction
C23 now has
type for N-bit integers (WG14 [N2763], [N2775]):
Possible implementations
𝔽 – Fundamental type | 𝕃 – Library type |
---|---|
𝔽 – Fundamentals can do more
A fundamental type is needed for full C compatibility:
A fundamental type could have deduction superpowers:
This could also be addressed by P2998, "Deducing function parameter types using alias template CTAD".
𝔽 – Why not reinvent integers?
Users have many grievances with the standard integers:
solves many issues in C, but not all (e.g. mixed-sign comp.)_BitInt - if fundamental in C++, could revamp integer types
𝔽 – Problems with a common spelling
- common spelling useful for C/C++-interoperable headers
- C uses the
and_BitInt ( N ) unsigned _BitInt ( N ) - C++ compatibility macro like
does not work_Atomic(...)
⇒ Both C and C++ developers would need a macro for unsigned types.
𝕃 – Class is easier to implement, teach
- P3140
got push-back for freestandingstd :: int_least128_t - MSVC does not even support 128-bit yet; no
implementation_BitInt - no compiler builtin required, no platform ABI changes
- many existing implementations (e.g. Boost.Multiprecision)
- conversion, overload resolution more easily explained
𝕃 – Fundamentals have huge blast radius
- new family of integer types
- countless uses of "integer" in wording revised
- integral promotion/conversion rules, template deduction rules
- library support is tough if bit-precise integers widely supported:
- N-bit
,<numeric>
,<bit>
,<simd> <linalg> - N-bit
,<charconv> <format> - […]
- N-bit
- library types could have more limited/gradual adoption
Summary
Key arguments (see [P3639R0] for more):
- 𝔽 – Fundamentals can do more
- 𝔽 – Why not reinvent integers?
- 𝔽 – Problems with a common spelling
- 𝕃 – Class is easier to implement, teach
- 𝕃 – Fundamentals have huge blast radius
Author position: neutral / slightly 𝔽
References
[P3639R0]
The _BitInt Debate
2025-02-20
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3639r0.html
[N1744]
Big Integer Library Proposal for C++0x
2005-01-13
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1744.pdf
[P1889R1]
C++ Numerics Work In Progress
2019-12-27
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1889r1%2epdf
[N2763]
Adding a Fundamental Type for N-bit integers
2021-06-21
https://open-std.org/JTC1/SC22/WG14/www/docs/n2763.pdf
[N2775]
Literal suffixes for bit-precise integers
2021-07-13
https://open-std.org/JTC1/SC22/WG14/www/docs/n2775.pdf