Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store a very large number in c++ [duplicate]

Tags:

c++

Is there any way to store a 1000 digit number in c++? I tried storing it to an unsigned long double but it is still to large for its type.

like image 380
wazalak Avatar asked Apr 23 '15 00:04

wazalak


2 Answers

You may find your answer here How to store extremely large numbers? GMP answer sounds right, ie this is what it does with pi digits https://gmplib.org/pi-with-gmp.html

like image 161
sed Avatar answered Oct 05 '22 23:10

sed


You have to implement it yourself or use a library for it. In particular I love GMP: https://gmplib.org/ , which is an C implementation of Big Int/Float and has C++ wrapper

like image 39
MasterID Avatar answered Oct 06 '22 00:10

MasterID