Unlimited storage for variables in C++

Hello dear C++ community !
I am working on a project and I need to save and work on very big numbers,
let me take u an example :
e.g I want to find the biggest prime number ( 2,3,5,7,... ) but I just know about int, double and etc. which have unlimited storages .

Please help me by telling me how to save very big numbers on the memory and use them ?

Tnx a lot ...
well, it is impossibile to find biggest prime number overall (infinity and stuff). If you consider 64 bit INT type you can find prime number in range of
0 to 18,446,744,073,709,551,615. I really doubt it is not enough for you project.
Last edited on
http://www.cplusplus.com/reference/climits/

What is the max limit of unsigned long long int on your platform? Not enough?

Beyond that, you would probably use std::string as storage and provide numerical operators.


However, finding the largest prime so far is not exactly a novel task; there are algorithms for that. How did they solve that issue? You should not reinvent a wheel, unless yours will have a more fascinating number of vertices.
Thanks dear friend for answers.
I just said and example . And ur answers were really useful.
I mean @ all, is there any variable that can save whatever we want in it without limitation and let it use all the computer storage if it's needed ?
Like generating the biggest prime number that our computer can calculate ? ( in an unlimited "for" ) ?

Thank you .
You would want to get a bignum library in that case. Go do a search and you should easily be able to find a couple.
Please refer to: http://software.intel.com/en-us/articles/memory-limits-applications-windows

As you can see, when dynamically allocating memory you can easly use up all available RAM.

There is also no problem in storing all the data in HDD, though if you would want to re-use that data for calculation, your program would be way slower.
Topic archived. No new replies allowed.