As you know, in this reason, 64-bit C++ compilers are temporarily disabled.
In order to keep using __int128 (at least partially) in 32-bit compilers, I'm trying writing a template of the unsigned version of __int128.
Here's it (not completed yet):
integer_128_impl.cpp
#include<climits>
namespace RedshiftShine{
using ll=unsigned long long;
const ll ulmx=ULLONG_MAX;
const ll shift=32;
ll min(ll x,ll y){
return x<y?x:y;
}
ll max(ll x,ll y){
return x>y?x:y;
}
bool detect_overflow_add(ll x,ll y){
return x+y<min(x,y);
}
bool detect_overflow_minus(ll x,ll y){
return x-y>max(x,y);
}
class Custom_Unsigned_int128{
private:
ll higherInt,lowerInt;
public:
Custom_Unsigned_int128(){}
template<typename _Tp>
Custom_Unsigned_int128(_Tp x):
higherInt(0),
lowerInt(x){}
template<typename _Tp>
Custom_Unsigned_int128(_Tp x,_Tp y):
higherInt(x),
lowerInt(y){}
Custom_Unsigned_int128
(const Custom_Unsigned_int128& ele):
higherInt(ele.higherInt),
lowerInt(ele.lowerInt){}
template<typename _Tp>
Custom_Unsigned_int128
operator=(const _Tp& x){
higherInt=0;
lowerInt=x;
}
Custom_Unsigned_int128
operator=(const Custom_Unsigned_int128& x){
higherInt=x.higherInt;
lowerInt=x.lowerInt;
}
template<typename _Tp>
Custom_Unsigned_int128
operator+(const _Tp& x){
return Custom_Unsigned_int128
{
higherInt+
detect_overflow_add(lowerInt,x),
lowerInt+x
};
}
Custom_Unsigned_int128
operator+(const Custom_Unsigned_int128& x){
return Custom_Unsigned_int128
{
higherInt+x.higherInt+
detect_overflow_add(lowerInt,x.lowerInt),
lowerInt+x.lowerInt
};
}
template<typename _Tp>
Custom_Unsigned_int128
operator-(const _Tp& x){
return Custom_Unsigned_int128
{
higherInt-
detect_overflow_minus(lowerInt,x),
lowerInt-x
};
}
Custom_Unsigned_int128
operator-(const Custom_Unsigned_int128& x){
return Custom_Unsigned_int128
{
higherInt-x.higherInt-
detect_overflow_minus(lowerInt,x.lowerInt),
lowerInt-x.lowerInt
};
}
template<typename _Tp>
Custom_Unsigned_int128
operator&(const _Tp& x){
return Custom_Unsigned_int128
{
higherInt,
lowerInt&x
};
}
Custom_Unsigned_int128
operator&(const Custom_Unsigned_int128& x){
return Custom_Unsigned_int128
{
higherInt&x.higherInt,
lowerInt&x.lowerInt
};
}
template<typename _Tp>
Custom_Unsigned_int128
operator|(const _Tp& x){
return Custom_Unsigned_int128
{
higherInt,
lowerInt|x
};
}
Custom_Unsigned_int128
operator|(const Custom_Unsigned_int128& x){
return Custom_Unsigned_int128
{
higherInt|x.higherInt,
lowerInt|x.lowerInt
};
}
template<typename _Tp>
Custom_Unsigned_int128
operator^(const _Tp& x){
return Custom_Unsigned_int128
{
higherInt,
lowerInt^x
};
}
Custom_Unsigned_int128
operator^(const Custom_Unsigned_int128& x){
return Custom_Unsigned_int128
{
higherInt^x.higherInt,
lowerInt^x.lowerInt
};
}
};
}
Hope it helps.