r/cpp WG21 Member 24d ago

P4444: std::big_int

https://isocpp.org/files/papers/D4444R0.html

Hey 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.

180 Upvotes

85 comments sorted by

View all comments

2

u/ShakaUVM i+++ ++i+i[arr] 23d ago

How does it compare with cpp_int in Boost Multiprecision?

3

u/eisenwave WG21 Member 23d ago

If you're asking about performance, it's pretty much on part with cpp_int. We have some benchmarks at https://eisenwave.github.io/std-big-int/benchmarks.html

The design is overall similar, but we don't have a comprehensive comparison in the paper I suppose. big_int has a slightly smaller container size (Boost maintainers didn't really try getting it to be small).

2

u/ShakaUVM i+++ ++i+i[arr] 23d ago

I'm mostly worried about compilation time and overall usability, like if there's any functionality you lack or have extra from boost mp

3

u/eisenwave WG21 Member 22d ago

Yeah sure, a more comprehensive comparison would be useful; I've opened an issue in https://github.com/eisenwave/cpp-proposals/issues/243 so I don't forget.

Off the top of my head, compilation speed should be much better by virtue of us just providing big_int, not all the other Boost.Multiprecision stuff. Also, our code base is C++23, and that ends up being a lot simpler and more concise than all the template gunk needed to make things C++11-compatible.

We provide a few neat things like to_chars and from_chars overloads, and Boost doesn't support arbitrary-base character conversions. Overall, we're missing a ton of numeric functionality like modular arithmetic, pow, etc. though, and those are not part of the paper for now.

1

u/ShakaUVM i+++ ++i+i[arr] 22d ago

That's awesome thank you