Hello

Why will the following code output integer c as 0 (null)?

Code:
```unsigned int c = pow( (double)2 , (double)1000);
std::cout << c << "\n";```
What would be the proper way of calculating 2^1000 in c++?

Thanks a lot!

2. An unsigned int is unable to store values larger than 2^32.

I believe a double would be able to store it. Otherwise you would need a to use a bignum library.

3. Even if a double can store it, it won't be with infinite precision. You will only get a few significant figures.

If you want the answer with infinite precision, you will have to use a bignum library.

4. Originally Posted by Waterbottle
An unsigned int is unable to store values larger than 2^32.

I believe a double would be able to store it. Otherwise you would need a to use a bignum library.
Actually: (2^32)-1 is the largest you can fit in a 32-bit integer.

A double should be able to store 1.07E301, which is roughly the value of 2^1000.

--
Mats

5. Oh and just poking, but in C++, it is really in our best to use the C++ variants of the C functions, std::pow.
There should be one, no?