Large fixed length integers

I am looking for a library for large integers, but with a fixed width (128 or 256 will be enough). The reason is that I do not want to heap allotment. I tried to make them myself, but the implementation of multiplication, division and a phased effective way seems rather sick.

Does it already exist somewhere?

thanks

+6
c ++ c biginteger
source share
3 answers

Take a look at the GMP library: www.gmplib.org

Quote from function categories:

A low-level positive integer, hard-to-reach, very low function overheads are in the mpn category. No memory management is performed; The caller must provide enough space for the results. (...)

This is similar to what you need.

+4
source share

This at least looks promising (press 8 for int128 library ).

http://www.mx-3.cz/tringi/www/langen.php?id=int128

"Unlike other classes of a large number, you can work with them in the same way as with other types of PODs (for example, store and load files using fwrite / fread). The internal representation of this data is the correct 128-bit low-end integer number."

+3
source share

If you find that GMP is too complicated for your taste, Dave Hanson has very good features in his book C Interfaces and Implementations . There is a low-level interface that does not highlight the allocation (you are in control), and then there are two higher-level interfaces that gradually control the allocation on the heap.

+2
source share

All Articles