If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Large integer datatypes in C++

Lately I've started working on programs that would require me to compute quite large values like those in the order of 10**10. I wrote my own exponentiation function after reading up the 'exponentiation by squaring' algorithm as the cmath function, pow() can return upto long double only which is totally unsuitable for my needs. But the problem is even after specifying the return type as long long unsigned, it seems the return value is too large to fit in it and instead I get a return value of 0.

I have seen some people using uint32_t and uint64_t datatypes, but I'm not sure what exactly they do. Can somebody guide me in this direction?

thanks a lot, nihil.
That should work for all my local computation needs. But, that brings me to another question. You must've seen the online coding contests where you submit your code to the online compiler and get results instantly. I can't use any extra libraries in that case and I've always wondered how those working in C++ manage to handle those large numbers with built-in data types.

PS: I could've worked the problems out on python, but speed is a major factor.

the first link was interesting, reminded me to poke around the /usr/include/limits.h file. I found that a constant _WORDSIZE in bits/wordsize.h that would determine the max size of long unsigned. I'm on a 32 bit system, so that makes it 2**32-1. But I don't think that would depend upon the compiler if I'm using the new compilers that conform to the latest C++ standards. Maybe it would have been a different matter if I was using something like Borland Turbo!

I have previously worked with GMP, but found the documentation quite cumbersome to follow

"When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
"There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
"Mischief my ass, you are an unethical moron." - chshBlog of X

Thank you very much, could you please send me all those lists of libraries which are used for large number of bits,or used in RSA, Is MPUINT also used for this purpose if yes ?Then could you please tell me about its funtionality?

I don't know much about large integer types in C++, but i did a course in assembly, and for very large numbers we did multiple operations using a couple of 32bit registers, i.e. you had to add a 64 bit number stored in two 32 bit registers, you'd add with carry and display the number by putting the two registers together. So you could use the largest integer type twice, and just carry the number over to the next order integer, so store a very large number in two variables instead of one. If that makes any sense and/or is possibly in C++.