numeric values bigger than ULLONG_MAX

2019-07-19 15:26发布

问题:

I need to store and use numeric values bigger than ULLONG_MAX.

I will need to make arithmetic operations with those values, so I think store as char** is not a option.

Is there a way to dynamically create an additional long prefix in those cases?


Thank you all. Based on responses, Very helpful but I doubt about the best performance option. piokuc quote a performance link, but it's unclear. In this time I'm between GMP or MPIR, there is some one faster?

回答1:

You need to use one of the arbitrary precision arithmetic libraries, like GMP, see also What's the best (for speed) arbitrary-precision library for C++?



回答2:

In addition to multi-precision libraries such as GMP, if you are using GCC on a 64-bit architecture, you also have the option of using __int128 (documentation).