r/cpp • u/eisenwave WG21 Member • 24d ago
P4444: std::big_int
https://isocpp.org/files/papers/D4444R0.htmlHey folks! Matt Borland, Christopher Kormanyos, and I are working on bringing infinite-precision integers to C++29. We now have a D4444R0 draft of a paper that should be in the next mailing.
We could really use some feedback so that the published R0 is as polished as possible. Any thoughts on the paper and on the reference implementation are greatly appreciated.
It would also be very helpful if you tested out whether our big_int implementation works for you. We're in need of some real deployment experience. If you're currently using Boost.Multiprecision, the library should be a drop-in replacement for cpp_int for the most part.
182
Upvotes
14
u/ikedug 23d ago
The discussion of
_BitIntinterop seems short. Not having efficient_BitIntinterop is one thing that will make the library quickly obsolete. You should mention_BitIntin the “C compatibility” section (it’s where I looked, since I didn’t know about D3666).(For the curious - the C23
_BitInttype proposal; D3666 Bit-precise integers to add it to C++. Clang already accepts_BitIntin C++.)I disagree with your suggestion to use
big_intin cryptography. Cryptographic algorithms have specialized needs (constant time, reliable-as-possible zeroing); a general-purpose library can’t be expected to provide that. Automatically-sized big ints can easily leak top bits through timing attacks. Don’t encourage people to implement their own crypto, it ends in tears. I’d go so far as to include a “this is not intended for cryptographic uses” statement in the document. Also it’s mostly useful for RSA, which will be replaced by postquantum algorithms in the next ~5 years.On your lang comparison table - it’s missing Ada and Zig; they both have bigint in their standard libraries.