The largest data type for positive integers I know of is unsigned long long. Is there a way to work on integers as large as 2^9000000 in C++. I use gcc compiler in code-blocks but can also work on visual studio.
You need some kind of BigInt library. I personally prefer boost.multiprecision, as it contains most of the utilities an average code writer would need.
In terms of what you actually want to use, there's two obvious types to consider.
boost::multiprecision::cpp_int
is the way to go, which will store a number as big as 2^9000000 by allocating approximately 9 million bits of data (slightly more than one megabyte) and storing the entire number in there.cpp_bin_float
backend, although for that you'd probably have to define your own template, since the prebaked versions probably aren't big enough.For the latter, a potential example:
using namespace boost::multiprecision;
using my_big_float = number<backends::cpp_bin_float<100, backends::digit_base_2, void, boost::int32_t, -9000000, 9000000>, et_off>;
//Defines the number to have 100 bits of precision, an exponent range from negative
//nine million to positive nine million, and uses 32-bit ints for the internal representation
//of the exponent. Allocator is void (because we don't need it) and et_off just turns off
//expression templates, which we don't need
int main() {
my_big_float fl = 5;
fl = pow(fl, my_big_float{900007});
std::cout << fl << std::endl;
}
7.88302e+629077
I don't know what your use-case is, but my guess is that the latter is going to be much better for your use-case than the former. You'll have to decide for yourself what the case is.