What type to use for integers larger than 2^32 in C++?
Use long long
and if possible add a compile-time assertion that this type is wide enough (smth like sizeof( long long ) >= 8
).
double
is for floating-point, not integer.
Try:
http://gmplib.org/ big num.
http://mattmccutchen.net/bigint/ big int.
I've used neither, but I've used similiar things in Java.
There is no portable way of doing this in C++, as the language does not specify the size of integer types (except sizeof char is 1). You need to consult your compiler documentation.