Reputation: 498
I find numeric limits of long long int insufficient. Is there any other numeric type in C++ like big integer in java?
I stumbled upon this question recently and didn't knew how to tackle it..... https://blog.codechef.com/2009/07/02/tutorial-for-small-factorials/
Upvotes: 1
Views: 52173
Reputation: 31
You can use the C++ library <boost/multiprecision/cpp_int.hpp>
for such problems.
For example:
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using namespace std;
int main()
{
cpp_int f = 1;
for(int i = 1; i <= 100; i++)
f *= i;
cout << "100! = " << f << '\n';
}
This will give the output
100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
To know more about C++ boost library, you can refer here and here
Upvotes: 3
Reputation: 2143
Type Name - long long
Bytes - 8
Range of Values - –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Ref: Microsoft
Upvotes: 6
Reputation: 374
unsigned long long int is biggest integer type in standard C++ ( it can hold numbers from 0 to 18 446 744 073 709 551 615 ), if you want bigger ones you may need to search for some bignum libraries like this: http://www.ttmath.org/
Upvotes: 12