I've got a problem where I need to read in from cin a positive decimal number that represents a value from 0 to 2^100. I then have to do some logic to it and spit it back out as a decimal. Obviously this is more than even an unsigned long long (which is 64 bits, I believe?) can handle, so what data types can I use, or what other tricks can I use?
You don't need to split anything, you just have to use cientific notation like you see in calculators, in C or C++ it's the same.
Eg.
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
int main()
{
float f = 10e+20; // 10^20
std::cout << f << std::endl;
std::cin.get();
return 0;
}
You can use that cientific notation from console also, and the stream will read it correctly ;)
Note: long variable time represents an long integer number, not a decimal number, so you can never represent an decimal number in a long variable, you have to use floating point variable types (float, double).