r/cpp • u/eisenwave WG21 Member • Aug 18 '26
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.
View all comments
Show parent comment
6
u/eisenwave WG21 Member Aug 18 '26 edited Aug 18 '26
There are several ways to get there. The few combinations of expressions that are truly special (like
v * k + w) typically have a dedicated spelling; that's an FMA and there isstd::fma/std::simd::fmafor that, and various numerics libraries have some kind of FMA customization point. Forbig_int, I don't think an FMA operation would actually accomplish much.Similarly, expression templates could help you with turning
pow(a, b) % minto amodpowautomatically, but you could have also just written it asmodpow.I feel like for the standard library, expression templates would be pretty exotic. It also moves too slowly to make that really feasible in my opinion. If you find some special combination like
-(-x)just beingxthat expression templates could have simplified, you're stuck waiting 3 years until the next C++ version anyway. In the meantime, you'll just have to rewrite your code.EDIT: I've added a section with my complete thoughts on expression templates to the paper: https://isocpp.org/files/papers/D4444R0.html#expression-templates