+ 5

Big Integer in C++

Look what I found! No more hastle of calculation of factorials of numbers > 100. #include <boost/multiprecision/cpp_int.hpp> #include <iostream> namespace mp = boost::multiprecision; using namespace std; int main() { mp::cpp_int u = 1; for(int i = 1; i <= 100; i++) u *= i; cout << "100! = " << u << '\n'; mp::cpp_int v = u / 100; cout << "99! = " << v << '\n'; }

10th Jan 2018, 2:21 AM
Aditya
Aditya - avatar
3 Antworten
+ 10
I found this in a pdf a while back which you may find interesting. (link to pdf in code). BigInt with native cpp/STL Boost library is better though imo. The pdf this is from is just a case study. https://code.sololearn.com/c0U2BqoJSrO1/?ref=app
10th Jan 2018, 2:57 AM
jay
jay - avatar
+ 9
the boost library is indeed useful for many things
10th Jan 2018, 2:54 AM
jay
jay - avatar
+ 6
If anyone is wondering. https://www.boost.org/
10th Jan 2018, 2:55 AM
Hatsy Rei
Hatsy Rei - avatar