In my project, I should get two numbers that are bigger than long long or etc. So I'm looking for a good solution.
-
Are you looking for a bignum library? – Blaze Oct 15 '19 at 07:16
-
1Your options are implementing your own string addition or downloading an external library. – Rokas Višinskas Oct 15 '19 at 07:19
-
1[Here's one I prepared earlier](https://stackoverflow.com/a/15375420/1553090) – paddy Oct 15 '19 at 07:21
-
Here are 2 big math libraries: https://gmplib.org/ or https://www.boost.org/doc/libs/1_71_0/libs/multiprecision/doc/html/boost_multiprecision/intro.html – drescherjm Oct 15 '19 at 07:24
1 Answers
C++ itself is not able to work with variables that have more then 64 bits. You either may implement it yourself, which I would strongly discourage you, or you use something well tested.
One of the best and well known libraries provides an solution for you: boost.
The Multiprecision Library provides integer, rational and floating-point types in C++ that have more range and precision than C++'s ordinary built-in types. The big number types in Multiprecision can be used with a wide selection of basic mathematical operations, elementary transcendental functions as well as the functions in Boost.Math. The Multiprecision types can also interoperate with the built-in types in C++ using clearly defined conversion rules. This allows Boost.Multiprecision to be used for all kinds of mathematical calculations involving integer, rational and floating-point types requiring extended range and precision.
Find all the information you need behind this Boost.Multiprecision

- 1,151
- 7
- 22