I am looking for a library for big integers but with fixed width (128 or 256 would be enough). The reason is I don't want any allocation on the heap. I tried to make them myself but implementing multiplication, division and modulo an efficient way seems to be quite a pain.
Does this already exists somewhere ?
Thanks
Take a look at the GMP library: www.gmplib.org
Quoting from the function categories:
Low-level positive-integer, hard-to-use, very low overhead functions are found in the mpn category. No memory management is performed; the caller must ensure enough space is available for the results. (...)
That seems to be what you need.
This at least looks promising (hit number 8 for int128 library
on Google).
http://www.mx-3.cz/tringi/www/langen.php?id=int128
"Unlike other large number classes, you can work with these just like with other P.O.D. types (for example store and load from files using fwrite/fread). Internal representation of these is correct 128-bit little-endian integer."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With