I want to multiply two numbers of sizes 10^10
, resulting size is 10^20
which is 2^66
.
I want to store that number in a standard datatype in C. I would rather not use "GNU MP Bignum library".
Why does the following C program not hold the number correctly?
#include<stdio.h>
typedef long long int ull;
int main(){
ull n1 = 10000000000LL;
ull n2 = 10000000000LL;
printf("%llu",n1*n2);
return 0;
}
What would be the best way to hold this number and work with it?
Store it as two
long long
values. Here's a sketch of a solution:Outputs: