As is said above. I want to make a simple calculator and even long long looks to short for my needs. How do I define bigger integer?
Thanks in advance.
How precize should they be? If the numbers dont need to be very precize, you could use a class with two members: a double for the value and a (long long) integer for the e-power (eg 5.24135 * 10^133).
You can also use 'pen and paper methods'. This means you calculate the answers number by number. For examplel, consider the following recursive function to divide numbers very precizely:
int size=1000;
int count=0;
//userinput:
int numerator;
int denominator;
void getAnswer (int count)
{
cout<<numerator/denominator;
if ( count<size)
{
if (count==0)
cout<<".";
numerator%=denominator;
numerator*=10;
count++;
getAnswer(count);
}
}
If you need full precision and arbitrarily long numbers, you should google "arbitrary precision arithmetic". I'd say the most popular one is the GMP (GNU MP Bignum Library). The only constraint in size is available memory.
Other than bignums, the largest datatype in C++ is the long double. In 32-bit systems, a 96-bit floating precision value. Pocket calculators use double, so I doubt you'll need a larger number than that. Unless, of course, you want to compute 2^(256^2), which I think it's totally acceptable.
Not necessarily. The only requirement is that sizeof( long double ) >= sizeof( double ). For example, in MSVC++ a long double is 64 bits -- just like a regular double.
I believe that the GCC will give you the 80-bit IEEE double extended precision if you ask for it (via options).