I need to store 2^63 natural number in my program. Int has 4 bytes: http://www.cplusplus.com/doc/tutorial/variables/ so it is 2^(8*4) = 2^32, which type should I use?
You can use unsigned long long
, but I would check that your compiler supports that type.
#include <iostream>
int main()
{
std::cout<<sizeof(unsigned long long)<< " bytes" << std::endl;
return 0;
}
Prints 8 bytes
on my machine which is enough room to store 2^63.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With