Instead of defining datatypes with preset sizes for big integers in C (like GMP and other libraries do), why not define operations on them for arbitrarily sized character arrays so that you can define how large you want your integer to be?
Name:
Anonymous2013-04-25 18:08
typedef struct bigint {
char *n;
int size;
} bigint;
/* set size in number of digits and initialize to 0 */
bigint set_size(int bytes) {
int i;
bigint r;
r.size = bytes;
r.n = (char *) malloc(bytes);
for(i = 0; i < bytes; i++) {
r.n[i] = '0';
}
return(r);
}
Of course this requires the user to know he has to free that at some point, but other than that, it seems pretty flexible and powerful.