I'm trying to calculate 2 ** 128 with c++, but it overflows, and I get a value of 0. any ideas on how to calculate this?? I also need to get it on a terminal, but iostream and stdio.h do not support one I tried called __int128.
#include <cstring>
int main(){
unsigned __int128 a = 2;
for(int i; i < 129; i++){
a = a * 2;
}
std::cout << a << std::endl;
}
or
#include <iostream>
#include <cstring>
int main(){
long long unsigned int a = 2;
for(int i; i < 129; i++){
a = a * 2;
}
std::cout << a << std::endl;
}
are the codes that I tried.