How to store 1,000,000 digital integers in C ++

in my problem, I have to save large large integers, for example, up to 1,000,000 digits and do some operation. How can i do this. I know a long int in C ++ can store up to 10 digits

+3
source share
1 answer

You can use GMP , the GNU arbitrary precision library. Just keep in mind that this is not a good library if you run out of memory.

By this, I mean that he will just step out from under you if he cannot allocate memory. I find this ... interesting ... an architectural solution for a general purpose library, but it is popular for this kind of thing, so if you are willing to wear this restriction, this is probably a good choice.

Another good one is MPIR , the GMP fork, which, despite the name "multiple precision integers and rationals," handles floating point pretty well. I found that these guys are much more useful than GMP developers when you ask for help or offer improvements (but just keep in mind that my experience, your mileage may vary).

+8
source

Source: https://habr.com/ru/post/1792733/


All Articles