Dylan Cleaver
Dylan Cleaver

Reputation: 63

Store very big numbers in an integer in C

I need to store a very large number as an integer in a C program, unsigned long int is still too small, I need a very large data type that will still work with the modulo operator (%).

Upvotes: 2

Views: 7355

Answers (2)

mexok
mexok

Reputation: 89

I just want to throw in another library to solve this problem, which I just finished:

It is more lightweight than the previous mentioned libraries. Please be sure that it still solves your needs, as there are some limitations.

As an example you might do modulo operations like this:

char i[20] = "5005";
kmbint_mod(i, "10");
// i is now "5"

Upvotes: 0

Pankrates
Pankrates

Reputation: 3095

There are several libraries that can do this

If you need it for cryptographic purposes (e.g. RSA as hinted by your need of modulo arithmetic), OpenSSL BN is ideally suited

Upvotes: 5

Related Questions